#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf

using namespace std;

const int maxn = 20020;
const int maxx = 10000;
const int MOd = 1e9+7;
const int K = 750;
const int P = 143;

typedef long long Lint;
typedef double db;
typedef pair<Lint,Lint> ii;
typedef pair<ii,int> iii;

int a, b, T, n;
int s[maxn], ar[maxn];
//~ ii sagment[1<<16];

//~ ii merge( ii a, ii b ) {
	//~
//~ }
//~
//~ void up( int k, int x ) {
	//~ k += n-1;
	//~ segment[k].fi += x;
	//~ if( segment[k].fi == 1 ) segment[k].se = 1;
	//~ if( segment[k].fi == 0 ) segment[k].se = 0;
	//~ for(k>>=1;k;k>>=1)
		//~ segment[k] = merge( segment[k] );
//~ }

void bit() {
	printf("No solution\n");
	exit(0);
}

int main() {

	scanf("%d %d %d",&a,&b,&T);

	//~ n = 1;
	//~ while( n < a ) n <<= 1;

	for(int i=1,j,k,l;i<=a;i++) {
		char c, ch;
		scanf(" %d %c %d %c %d",&j,&c,&k,&ch,&l);
		ar[i] = j * 3600 + k * 60 + l;
	}
	sort( ar+1, ar+1+a );
	int sz = 0;
	int ans[maxn], next = 0;
	int h = 0;
	for(int i=1,j=1;i<=a;i++) {
		while( j < i && ar[j]+T <= ar[i] ) {
			s[ans[j]]--;
			if( s[ans[j]] == 0 ) sz--;
			j++;
		}
		if( sz == b ) {
			h = 1;
			s[ans[i-1]]++;
			ans[i] = ans[i-1];
		} else {
			if( next < a ) next++;
			ans[i] = next;
			s[next]++;
			sz++;
		}
	}
	if( !h ) bit();

	printf("%d\n",next);

	for(int i=1;i<=a;i++)
		printf("%d\n",ans[i]);

	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf

using namespace std;

const int maxn = 20020;
const int maxx = 10000;
const int MOd = 1e9+7;
const int K = 750;
const int P = 143;

typedef long long Lint;
typedef double db;
typedef pair<Lint,Lint> ii;
typedef pair<ii,int> iii;

int a, b, T, n;
int s[maxn], ar[maxn];
//~ ii sagment[1<<16];

//~ ii merge( ii a, ii b ) {
	//~
//~ }
//~
//~ void up( int k, int x ) {
	//~ k += n-1;
	//~ segment[k].fi += x;
	//~ if( segment[k].fi == 1 ) segment[k].se = 1;
	//~ if( segment[k].fi == 0 ) segment[k].se = 0;
	//~ for(k>>=1;k;k>>=1)
		//~ segment[k] = merge( segment[k] );
//~ }

void bit() {
	printf("No solution\n");
	exit(0);
}

int main() {

	scanf("%d %d %d",&a,&b,&T);

	//~ n = 1;
	//~ while( n < a ) n <<= 1;

	for(int i=1,j,k,l;i<=a;i++) {
		char c, ch;
		scanf(" %d %c %d %c %d",&j,&c,&k,&ch,&l);
		ar[i] = j * 3600 + k * 60 + l;
	}
	sort( ar+1, ar+1+a );
	int sz = 0;
	int ans[maxn], next = 0;
	int h = 0;
	for(int i=1,j=1;i<=a;i++) {
		while( j < i && ar[j]+T < ar[i] ) {
			s[ans[j]]--;
			if( s[ans[j]] == 0 ) sz--;
			j++;
		}
		if( sz == b ) {
			h = 1;
			s[ans[i-1]]++;
			ans[i] = ans[i-1];
		} else {
			if( next < a ) next++;
			ans[i] = next;
			s[next]++;
			sz++;
		}
	}
	if( !h ) bit();

	printf("%d\n",next);

	for(int i=1;i<=a;i++)
		printf("%d\n",ans[i]);

	return 0;
}


// Aditya Shah

#include <bits/stdc++.h>
using namespace std;

const int N = 20005;
const int Period = 24 * 60 * 60 + 100;

set<pair<int,int>, greater<pair<int,int> > > activeSet;
set<pair<int,int>, greater<pair<int,int> > >::iterator it;
int input[N], a[N];
int start[Period];
vector<int> ans[Period];

int main() {
    //freopen("input.in", "r", stdin);
    int n, M, T, h, m, s, userID = 1;
    bool ok = false;
    scanf("%d %d %d", &n, &M, &T);
    for (int i = 0; i < n; ++i) {
        scanf("%d:%d:%d", &h, &m, &s);
        input[i] = (h * 60 + m) * 60 + s;
        a[i] = input[i];
        start[a[i]]++;
    }
    sort(a, a + n);
    for (int i = 0; i < Period; ++i) {
        while(1) {
            if (activeSet.size() == 0) break;
            it = activeSet.end(); it--;
            if (it->first < i) activeSet.erase(it);
            else break;
        }
        while (start[i] && activeSet.size() < M) {
            start[i]--;
            activeSet.insert(make_pair(i + T - 1, userID++));
            ans[i].push_back(userID-1);
        }
        while(start[i]--) {
            it = activeSet.begin();
            int idx = it->second;
            int val = i + T - 1;
            ans[i].push_back(idx);
            activeSet.erase(it);
            activeSet.insert(make_pair(val, idx));
        }
        if (activeSet.size() == M) {
            ok = true;
        }
    }
    if (!ok) {
        printf("No solution");
        return 0;
    }
    printf("%d\n", userID-1);
    for (int i = 0; i < n; ++i) {
        printf("%d\n", ans[input[i]].back());
        ans[input[i]].pop_back();
    }
    return 0;
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define FOR(i,j,k) for(int i = j; i < (int)(k); i++)
#define FORV(i, v) FOR(i, 0, ((v).size()))
#define REP(i,j,k) for(int i = j; i >= (int)(k); i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()
#define autodef(x,v) typeof(v) x = (v)
#define autoref(x,v) typeof(v)& x = (v)
#define forit(it, c) for (autodef(it, ((c).begin())); it != ((c).end()); ++it)

//typedef complex<double> Point;
//#define X real()
//#define Y imag()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

const int INF = (int) 2e9;
const ll INFL = (ll) 9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const ll MAXLL = ((~0) ^ ((ll)1 << 63));

template<class T> inline T pow2(T a) { return a*a;}
template<class T> inline bool mineq(T& a, T b){return (a > b) ? (a=b, true) : false;}
template<class T> inline bool maxeq(T& a, T b){return (a < b) ? (a=b, true) : false;}

//srand (time(NULL));

setmax(1e5+10);

int n,m,t, cnt, ans[maxn], id = 1;
vi out[maxn], in[maxn];
bool reachm = false;

multiset<int> st;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> m >> t;

    FOR(i,0,n)
    {
	int a,b,c, tim;
	scanf("%d:%d:%d",&a,&b,&c);

	tim = a*3600 + b*60 + c;
	in[tim].pb(i);
    }

    FOR(i,0,maxn)
    {
	FOR(j,0,out[i].size())
	{
	    st.erase(st.find(out[i][j]));
	    if(st.find(out[i][j]) == st.end())
		cnt--;
	}

	FOR(j,0,in[i].size())
	{
	    int p = in[i][j];
	    if(cnt < m)
	    {
		ans[p] = id++;
		st.insert(ans[p]);
		out[i+t].pb(ans[p]);

		cnt++;
	    }
	    else
	    {
		ans[p] = *st.begin();
		st.insert(ans[p]);
		out[i+t].pb(ans[p]);
	    }

	    if(cnt == m)
		reachm = true;
	}
    }

    if(!reachm)
    {
	cout << "No solution";
	return 0;
    }

    cout << *max_element(ans,ans+n) << "\n";
    FOR(i,0,n)
	cout << ans[i] << "\n";
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define FOR(i,j,k) for(int i = j; i < (int)(k); i++)
#define FORV(i, v) FOR(i, 0, ((v).size()))
#define REP(i,j,k) for(int i = j; i >= (int)(k); i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()
#define autodef(x,v) typeof(v) x = (v)
#define autoref(x,v) typeof(v)& x = (v)
#define forit(it, c) for (autodef(it, ((c).begin())); it != ((c).end()); ++it)

//typedef complex<double> Point;
//#define X real()
//#define Y imag()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

const int INF = (int) 2e9;
const ll INFL = (ll) 9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const ll MAXLL = ((~0) ^ ((ll)1 << 63));

template<class T> inline T pow2(T a) { return a*a;}
template<class T> inline bool mineq(T& a, T b){return (a > b) ? (a=b, true) : false;}
template<class T> inline bool maxeq(T& a, T b){return (a < b) ? (a=b, true) : false;}

//srand (time(NULL));

setmax(1e5+10);

int n,m,t, cnt, ans[maxn], id = 1;
vi out[maxn], in[maxn];
bool reachm = false;

deque<int> dq;
multiset<int> st;

int main()
{
   // ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> m >> t;

    FOR(i,0,n)
    {
	int a,b,c, tim;
	scanf("%d:%d:%d",&a,&b,&c);

	tim = a*3600 + b*60 + c;
	in[tim].pb(i);
    }

    FOR(i,0,maxn)
    {
	FOR(j,0,out[i].size())
	{
	    dq.pop_front();
	    st.erase(st.find(out[i][j]));
	    if(st.find(out[i][j]) == st.end())
		cnt--;
	}

	FOR(j,0,in[i].size())
	{
	    int p = in[i][j];
	    if(cnt < m)
	    {
		ans[p] = id++;
		st.insert(ans[p]);
		dq.pb(ans[p]);
		out[i+t].pb(ans[p]);

		cnt++;
	    }
	    else
	    {
		ans[p] = dq.back();
		st.insert(ans[p]);
		dq.pb(ans[p]);
		out[i+t].pb(ans[p]);
	    }

	    if(cnt == m)
		reachm = true;
	}
    }

    if(!reachm)
    {
	cout << "No solution";
	return 0;
    }

    cout << *max_element(ans,ans+n) << "\n";
    FOR(i,0,n)
	cout << ans[i] << "\n";
}


/*
ID: keyvank2
TASK: combo
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define FOR(i,j,k) for(int i = j; i < (int)(k); i++)
#define FORV(i, v) FOR(i, 0, ((v).size()))
#define REP(i,j,k) for(int i = j; i >= (int)(k); i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()
#define autodef(x,v) typeof(v) x = (v)
#define autoref(x,v) typeof(v)& x = (v)
#define forit(it, c) for (autodef(it, ((c).begin())); it != ((c).end()); ++it)

//typedef complex<double> Point;
//#define X real()
//#define Y imag()

using namespace std;

//ifstream fin("");
//ofstream fout("");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

const int INF = (int) 2e9;
const ll INFL = (ll) 9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const ll MAXLL = ((~0) ^ ((ll)1 << 63));

template<class T> inline T pow2(T a) { return a*a;}
template<class T> inline bool mineq(T& a, T b){return (a > b) ? (a=b, true) : false;}
template<class T> inline bool maxeq(T& a, T b){return (a < b) ? (a=b, true) : false;}

//srand (time(NULL));

setmax(1e5+10);

int n,m,t, cnt, ans[maxn], id = 1;
vi out[maxn], in[maxn];
bool reachm = false;

multiset<int> st;

int main()
{
   // ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> m >> t;

    FOR(i,0,n)
    {
	int a,b,c, tim;
	scanf("%d:%d:%d",&a,&b,&c);

	tim = a*3600 + b*60 + c;
	in[tim].pb(i);
    }

    FOR(i,0,maxn)
    {
	FOR(j,0,out[i].size())
	{
	    st.erase(st.find(out[i][j]));
	    if(st.find(out[i][j]) == st.end())
		cnt--;
	}

	FOR(j,0,in[i].size())
	{
	    int p = in[i][j];
	    if(cnt < m)
	    {
		ans[p] = id++;
		st.insert(ans[p]);
		out[i+t].pb(ans[p]);

		cnt++;
	    }
	    else
	    {
		ans[p] = *st.begin();
		st.insert(ans[p]);
		out[i+t].pb(ans[p]);
	    }

	    if(cnt == m)
		reachm = true;
	}
    }

    if(!reachm)
    {
	cout << "No solution";
	return 0;
    }

    cout << *max_element(ans,ans+n) << "\n";
    FOR(i,0,n)
	cout << ans[i] << "\n";
}


#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;

int n, M, T;
int res;
vector <int> seq;
deque <ii> D;
bool was;

int getTim(char s[])
{
	int h = (s[0] - '0') * 10 + s[1] - '0';
	int mn = (s[3] - '0') * 10 + s[4] - '0';
	int sc = (s[6] - '0') * 10 + s[7] - '0';
	return sc + 60 * (mn + 60 * h);
}

int main()
{
	scanf("%d %d %d", &n, &M, &T);
	char str[15];
	for (int i = 0; i < n; i++) {
		scanf("%s", str);
		int tim = getTim(str);
		if (!D.empty() && D[0].first < tim) D.pop_front();
		if (D.size() < M) {
			D.push_back(ii(tim + T - 1, ++res));
			seq.push_back(res);
		} else {
			D.back().first = tim + T - 1;
			seq.push_back(D.back().second);
		}
		if (D.size() == M) was = true;
	}
	if (was) {
		printf("%d\n", res);
		for (int i = 0; i < seq.size(); i++)
			printf("%d\n", seq[i]);
	} else printf("No solution\n");
	return 0;
}


#include <cstdio>

#define N 20010

int s[N], ans[N];
int Q[N];

main() {
//	freopen("D.in.txt", "r", stdin);
	int n, m, T;
	int h = 1, t = 0, cnt = 0;
	scanf("%d %d %d", &n, &m, &T);
	bool bf = 0;
	for (int i = 1; i <= n; i ++) {
		int hh, mm, ss;
		scanf("%d:%d:%d", &hh, &mm, &ss);
		s[i] = (hh * 60 + mm) * 60 + ss;
		Q[++ t] = i;
		while (h <= t) {
			int cur = Q[h];
			if (s[cur] + T <= s[i]) h ++;
			else break;
		}
		int frt = ans[h];
		if (cnt - frt + 1 == m) ans[i] = cnt;
		else ans[i] = ++ cnt;
		if (cnt - ans[h] + 1 == m) bf = 1;
	}
	if (!bf) puts("No solution");
	else {
		printf("%d\n", cnt);
		for (int i = 1; i <= n; i ++) printf("%d\n", ans[i]);
	}
}


#include <cstdio>

#define N 20010

int s[N], ans[N];
int Q[N];

main() {
//	freopen("D.in", "r", stdin);
	int n, m, T;
	int h = 1, t = 0, cnt = 0;
	scanf("%d %d %d", &n, &m, &T);
	bool bf = 0;
	for (int i = 1; i <= n; i ++) {
		int hh, mm, ss;
		scanf("%d:%d:%d", &hh, &mm, &ss);
		s[i] = (hh * 60 + mm) * 60 + ss;
		Q[++ t] = i;
		while (h <= t) {
			int cur = Q[h];
			if (s[cur] + T <= s[i]) h ++;
			else break;
		}
		int frt = ans[h];
		if (cnt - frt + 1 == m) ans[i] = cnt;
		else ans[i] = ++ cnt;
		if (cnt - frt + 1 == m) bf = 1;
	}
	if (!bf) puts("No solution");
	else {
		printf("%d\n", cnt);
		for (int i = 1; i <= n; i ++) printf("%d\n", ans[i]);
	}
}


#include <cstdio>

#define N 20010

int s[N], ans[N];
int Q[N];

main() {
//	freopen("D.in.txt", "r", stdin);
	int n, m, T;
	int h = 1, t = 0, cnt = 0;
	scanf("%d %d %d", &n, &m, &T);
	bool bf = 0;
	for (int i = 1; i <= n; i ++) {
		int hh, mm, ss;
		scanf("%d:%d:%d", &hh, &mm, &ss);
		s[i] = (hh * 60 + mm) * 60 + ss;
		Q[++ t] = i;
		while (h <= t) {
			int cur = Q[h];
			if (s[cur] + T <= s[i]) h ++;
			else break;
		}
		if (h == t) ans[i] = ++ cnt;
		else {
            int frt = ans[h];
            if (cnt - frt + 1 == m) ans[i] = cnt;
            else ans[i] = ++ cnt;
		}
		if (cnt - ans[h] + 1 == m) bf = 1;
	}
	if (!bf) puts("No solution");
	else {
		printf("%d\n", cnt);
		for (int i = 1; i <= n; i ++) printf("%d\n", ans[i]);
	}
}


#include <stdio.h>
#include <map>
#include <algorithm>
using namespace std;
#define M 5005
int a[M];

int n, k;
map<int, int> mp;

void solve(int x) {
	int ans = k + 1;
	mp[0] = 0;
    for (int j = 2; j <= n; j++) {
		for (int i = 1; i <= k; i++) mp[i * a[j-1]] = i;
		for (int i = 1; i <= k; i++) {
			int u = x - a[j] * i;
			if (mp.count(u))
				ans = min(ans, mp[u] + i);
		}
    }
    printf("%d\n", ans <= k ? ans : -1);
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);

	int x, q;
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &x);
		solve(x);
	}
	return 0;
}


#include <cstdio>

#define N 20010
#define M 90000

int s[N];
int add[M];
int S[N], E[N], cnt;
int ans[N];
int c[N];

main() {
//	freopen("D.in", "r", stdin);
	int n, m, T;
	scanf("%d %d %d", &n, &m, &T);
	for (int i = 1; i <= n; i ++) {
		int hh, mm, ss;
		scanf("%d:%d:%d", &hh, &mm, &ss);
		s[i] = (hh * 60 + mm) * 60 + ss;
		add[s[i]] ++;
		add[s[i] + T] --;
	}
	int cur = 0;
	bool bf = 0;
	bool f = 0;
	for (int i = 0; i < 86400; i ++) {
		cur += add[i];
		if (!cur) {
			bf = 0;
			continue;
		} else {
			if (!bf) S[++ cnt] = i;
			E[cnt] = i;
			if (cur >= m) f = 1;
			bf = 1;
		}
	}
	if (!f) {
		puts("No solution");
		return 0;
	}
	cur = 1;
	int tot = 0;
	for (int i = 1; i <= n; i ++) {
		while (cur <= cnt && E[cur] < s[i]) cur ++;
		c[cur] ++;
		if (c[cur] <= m) ans[i] = ++ tot;
		else ans[i] = tot;
	}
	printf("%d\n", tot);
	for (int i = 1; i <= n; i ++) printf("%d\n", ans[i]);
}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<assert.h>
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)
#define per(i,j,k) for(int i=(j);i>=(int)k;i--)
#define lowbit(x) ((x)&(-(x)))
#define fi first
#define se second
#define pii pair<int,int>
#define VI vector<int>
#define S(x) x.size()
using namespace std;
typedef long long LL;
typedef double db;
const int N=200005;
int t[N];int ans[N];
multiset<int>use,nouse;
int c[N];int kind=0;
int main(){
	int n,M,T;
	scanf("%d%d%d",&n,&M,&T);
	rep(i,1,n){
		int h,m,s;
		scanf("%d:%d:%d",&h,&m,&s);
		t[i]=h*3600+m*60+s;
	}
	int R=0;int l=1;bool arrive=0;
	rep(i,1,n){
		while(t[l]+T-1<t[i]){
			use.erase(ans[l]);c[ans[l]]--;if(c[ans[l]]==0)kind--;
			l++;
		}
		if(kind==M){
			arrive=1;
			ans[i]=*(--use.end());
			c[ans[i]]++;use.insert(ans[i]);
		}
		else{
			ans[i]=++R;
			use.insert(ans[i]);
			c[ans[i]]++;
			kind++;
		}
	}
	if(!arrive){
		printf("No solution\n");
	}
	else{
		printf("%d\n",R);
		rep(i,1,n)printf("%d\n",ans[i]);
	}
}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<assert.h>
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)
#define per(i,j,k) for(int i=(j);i>=(int)k;i--)
#define lowbit(x) ((x)&(-(x)))
#define fi first
#define se second
#define pii pair<int,int>
#define VI vector<int>
#define S(x) x.size()
using namespace std;
typedef long long LL;
typedef double db;
const int N=20005;
int t[N];int ans[N];
multiset<int>use,nouse;
int c[N];int kind=0;
int main(){
	int n,M,T;
	scanf("%d%d%d",&n,&M,&T);
	rep(i,1,n){
		int h,m,s;
		scanf("%d:%d:%d",&h,&m,&s);
		t[i]=h*3600+m*60+s;
	}
	int R=0;int l=1;bool arrive=0;
	rep(i,1,n){
		while(t[l]+T-1<t[i]){
			use.erase(use.find(ans[l]));c[ans[l]]--;if(c[ans[l]]==0)kind--;
			l++;
		}
		if(kind==M){
                        if(!use.size())return 0;
			arrive=1;
			ans[i]=*(--use.end());
			c[ans[i]]++;use.insert(ans[i]);
		}
		else{
			ans[i]=++R;
			use.insert(ans[i]);
			c[ans[i]]++;
			kind++;
		}
	}
        if(kind==M)arrive=1;
	if(!arrive){
		printf("No solution\n");
	}
	else{
		printf("%d\n",R);
		rep(i,1,n)printf("%d\n",ans[i]);
	}
}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<assert.h>
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)
#define per(i,j,k) for(int i=(j);i>=(int)k;i--)
#define lowbit(x) ((x)&(-(x)))
#define fi first
#define se second
#define pii pair<int,int>
#define VI vector<int>
#define S(x) x.size()
using namespace std;
typedef long long LL;
typedef double db;
const int N=20005;
int t[N];int ans[N];
multiset<int>use,nouse;
int c[N];int kind=0;
int main(){
	int n,M,T;
	scanf("%d%d%d",&n,&M,&T);
	rep(i,1,n){
		int h,m,s;
		scanf("%d:%d:%d",&h,&m,&s);
		t[i]=h*3600+m*60+s;
	}
	int R=0;int l=1;bool arrive=0;
	rep(i,1,n){
		while(t[l]+T-1<t[i]){
			use.erase(ans[l]);c[ans[l]]--;if(c[ans[l]]==0)kind--;
			l++;
		}
		if(kind==M){
                        if(!use.size())return 0;
			arrive=1;
			ans[i]=*(--use.end());
			c[ans[i]]++;use.insert(ans[i]);
		}
		else{
			ans[i]=++R;
			use.insert(ans[i]);
			c[ans[i]]++;
			kind++;
		}
	}
	if(!arrive){
		printf("No solution\n");
	}
	else{
		printf("%d\n",R);
		rep(i,1,n)printf("%d\n",ans[i]);
	}
}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<assert.h>
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)
#define per(i,j,k) for(int i=(j);i>=(int)k;i--)
#define lowbit(x) ((x)&(-(x)))
#define fi first
#define se second
#define pii pair<int,int>
#define VI vector<int>
#define S(x) x.size()
using namespace std;
typedef long long LL;
typedef double db;
const int N=20005;
int t[N];int ans[N];
multiset<int>use,nouse;
int c[N];int kind=0;
int main(){
	int n,M,T;
	scanf("%d%d%d",&n,&M,&T);
	rep(i,1,n){
		int h,m,s;
		scanf("%d:%d:%d",&h,&m,&s);
		t[i]=h*3600+m*60+s;
	}
	int R=0;int l=1;bool arrive=0;
	rep(i,1,n){
		while(t[l]+T-1<t[i]){
			use.erase(use.find(ans[l]));c[ans[l]]--;if(c[ans[l]]==0)kind--;
			l++;
		}
		if(kind==M){
                        if(!use.size())return 0;
			arrive=1;
			ans[i]=*(--use.end());
			c[ans[i]]++;use.insert(ans[i]);
		}
		else{
			ans[i]=++R;
			use.insert(ans[i]);
			c[ans[i]]++;
			kind++;
		}
	}
	if(!arrive){
		printf("No solution\n");
	}
	else{
		printf("%d\n",R);
		rep(i,1,n)printf("%d\n",ans[i]);
	}
}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<assert.h>
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)
#define per(i,j,k) for(int i=(j);i>=(int)k;i--)
#define lowbit(x) ((x)&(-(x)))
#define fi first
#define se second
#define pii pair<int,int>
#define VI vector<int>
#define S(x) x.size()
using namespace std;
typedef long long LL;
typedef double db;
const int N=20005;
int t[N];int ans[N];
multiset<int>use,nouse;
int c[N];int kind=0;
int main(){
	int n,M,T;
	scanf("%d%d%d",&n,&M,&T);
	rep(i,1,n){
		int h,m,s;
		scanf("%d:%d:%d",&h,&m,&s);
		t[i]=h*3600+m*60+s;
	}
	int R=0;int l=1;bool arrive=0;
	rep(i,1,n){
		while(t[l]+T-1<t[i]){
			use.erase(ans[l]);c[ans[l]]--;if(c[ans[l]]==0)kind--;
			l++;
		}
		if(kind==M){
			arrive=1;
			ans[i]=*(--use.end());
			c[ans[i]]++;use.insert(ans[i]);
		}
		else{
			ans[i]=++R;
			use.insert(ans[i]);
			c[ans[i]]++;
			kind++;
		}
	}
	if(!arrive){
		printf("No solution\n");
	}
	else{
		printf("%d\n",R);
		rep(i,1,n)printf("%d\n",ans[i]);
	}
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 87000;

int n, M, T;
vector< int > E1[ N ], E2[ N ];
int P[ N ];

set< pii > S;
int ans[ N ];

void load( ) {
    scanf( "%d%d%d", &n, &M, &T );
    for( int i = 0; i < n; i++ ) {
        int h, m, s;
        scanf( "%d:%d:%d", &h, &m, &s );
        P[ i ] = h * 3600 + m * 60 + s;
        E1[ P[ i ] ].pb( i );
        E2[ P[ i ] + T - 1 ].pb( i );
    }
}

deque< int > DQ;

void solve( ) {
    bool ok = false;
    int cnt = 1;
    for( int i = 1; i <= 86400; i++ ) {
        for( int j = 0; j < E1[ i ].size( ); j++ ) {
            for( int j = 0; j < E2[ i ].size( ); j++ ) {
                int idx = E2[ i ][ j ];
                DQ.pop_front( );
            }
            int idx = E1[ i ][ j ];
            if( DQ.size( ) == M ) {
                int x = DQ.back( );
                DQ.pop_back( );
                ans[ idx ] = cnt-1;
                DQ.push_back( idx );
            }
            else {
                ans[ idx ] = cnt++;
                DQ.push_back( idx );
            }
            if( DQ.size( ) == M ) ok = true;
        }
    }
    if( !ok ) printf( "No solution\n" );
    else {
        printf( "%d\n", cnt-1 );
        for( int i = 0; i < n; i++ ) printf( "%d\n", ans[ i ] );
    }
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 87000;

int n, M, T;
vector< int > E1[ N ], E2[ N ];
int P[ N ];

set< pii > S;
int ans[ N ];

void load( ) {
    scanf( "%d%d%d", &n, &M, &T );
    for( int i = 0; i < n; i++ ) {
        int h, m, s;
        scanf( "%d:%d:%d", &h, &m, &s );
        P[ i ] = h * 3600 + m * 60 + s;
        E1[ P[ i ] ].pb( i );
        E2[ P[ i ] + T - 1 ].pb( i );
    }
}

deque< int > DQ;

void solve( ) {
    bool ok = false;
    int cnt = 1;
    for( int i = 1; i <= 86400; i++ ) {
        for( int j = 0; j < E1[ i ].size( ); j++ ) {
            int idx = E1[ i ][ j ];
            if( DQ.size( ) == M ) {
                int x = DQ.back( );
                DQ.pop_back( );
                ans[ idx ] = ans[ x ];
                DQ.push_back( idx );
            }
            else {
                ans[ idx ] = cnt++;
                DQ.push_back( idx );
            }
            if( DQ.size( ) == M ) ok = true;
        }
        for( int j = 0; j < E2[ i ].size( ); j++ ) {
            int idx = E2[ i ][ j ];
            DQ.pop_front( );
        }
    }
    if( !ok ) printf( "No solution\n" );
    else {
        printf( "%d\n", cnt );
        for( int i = 0; i < n; i++ ) printf( "%d\n", ans[ i ] );
    }
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 87000;

int n, M, T;
vector< int > E1[ N ], E2[ N ];
int P[ N ];

set< pii > S;
int ans[ N ];

void load( ) {
    scanf( "%d%d%d", &n, &M, &T );
    for( int i = 0; i < n; i++ ) {
        int h, m, s;
        scanf( "%d:%d:%d", &h, &m, &s );
        P[ i ] = h * 3600 + m * 60 + s;
        E1[ P[ i ] ].pb( i );
        E2[ P[ i ] + T - 1 ].pb( i );
        //printf( "P[ i ] == %d\n", P[ i ] );
    }
}

deque< int > DQ;

void solve( ) {
    bool ok = false;
    int cnt = 1;
    for( int i = 0; i < n; i++ ) {
        while( !DQ.empty( ) && P[ i ] - P[ DQ.front( ) ] >= T ) DQ.pop_front( );
        if( DQ.empty( ) ) {
            ans[ i ] = cnt++, DQ.push_back( i );
            if( DQ.size( ) == M ) ok = true;
        }
        else {
            if( DQ.size( ) >= M ) {
                int x = DQ.back( );
                DQ.pop_back( );
                ans[ i ] = ans[ x ];
            }
            else ans[ i ] = cnt++, DQ.push_back( i );
            if( DQ.size( ) == M ) ok = true;
        }
    }
    if( !ok ) printf( "No solution\n" );
    else {
        printf( "%d\n", cnt-1 );
        for( int i = 0; i < n; i++ ) printf( "%d\n", ans[ i ] );
    }
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 87000;

int n, M, T;
vector< int > E1[ N ], E2[ N ];
int P[ N ];

set< pii > S;
int ans[ N ];

void load( ) {
    scanf( "%d%d%d", &n, &M, &T );
    for( int i = 0; i < n; i++ ) {
        int h, m, s;
        scanf( "%d:%d:%d", &h, &m, &s );
        P[ i ] = h * 3600 + m * 60 + s;
        E1[ P[ i ] ].pb( i );
        E2[ P[ i ] + T - 1 ].pb( i );
    }
}

deque< int > DQ;

void solve( ) {
    bool ok = false;
    int cnt = 1;
    for( int i = 1; i <= 86400; i++ ) {
        for( int j = 0; j < E1[ i ].size( ); j++ ) {
            int idx = E1[ i ][ j ];
            if( DQ.size( ) == M ) {
                int x = DQ.back( );
                DQ.pop_back( );
                ans[ idx ] = ans[ x ];
                DQ.push_back( idx );
            }
            else {
                ans[ idx ] = cnt++;
                DQ.push_back( idx );
            }
            if( DQ.size( ) == M ) ok = true;
        }
        for( int j = 0; j < E2[ i ].size( ); j++ ) {
            int idx = E2[ i ][ j ];
            DQ.pop_front( );
        }
    }
    if( !ok ) printf( "No solution\n" );
    else {
        printf( "%d\n", cnt-1 );
        for( int i = 0; i < n; i++ ) printf( "%d\n", ans[ i ] );
    }
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 87000;

int n, M, T;
vector< int > E1[ N ], E2[ N ];
int P[ N ];

set< pii > S;
int ans[ N ];

void load( ) {
    scanf( "%d%d%d", &n, &M, &T );
    for( int i = 0; i < n; i++ ) {
        int h, m, s;
        scanf( "%d:%d:%d", &h, &m, &s );
        P[ i ] = h * 3600 + m * 60 + s;
        E1[ P[ i ] ].pb( i );
        E2[ P[ i ] + T - 1 ].pb( i );
    }
}

deque< int > DQ;

void solve( ) {
    bool ok = false;
    int cnt = 1;
    for( int i = 1; i <= 86400; i++ ) {
        for( int j = 0; j < E1[ i ].size( ); j++ ) {
            int idx = E1[ i ][ j ];
            if( DQ.size( ) == M ) {
                int x = DQ.back( );
                DQ.pop_back( );
                ans[ idx ] = cnt-1;
                DQ.push_back( idx );
            }
            else {
                ans[ idx ] = cnt++;
                DQ.push_back( idx );
            }
            if( DQ.size( ) == M ) ok = true;
        }
        for( int j = 0; j < E2[ i ].size( ); j++ ) {
            int idx = E2[ i ][ j ];
            DQ.pop_front( );
        }
    }
    if( !ok ) printf( "No solution\n" );
    else {
        printf( "%d\n", cnt-1 );
        for( int i = 0; i < n; i++ ) printf( "%d\n", ans[ i ] );
    }
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 87000;

int n, M, T;
vector< int > E1[ N ], E2[ N ];
int P[ N ];

set< pii > S;
int ans[ N ];

void load( ) {
    scanf( "%d%d%d", &n, &M, &T );
    for( int i = 0; i < n; i++ ) {
        int h, m, s;
        scanf( "%d:%d:%d", &h, &m, &s );
        P[ i ] = h * 3600 + m * 60 + s;
        E1[ P[ i ] ].pb( i );
        E2[ P[ i ] + T - 1 ].pb( i );
        printf( "P[ i ] == %d\n", P[ i ] );
    }
}

deque< int > DQ;

void solve( ) {
    bool ok = false;
    int cnt = 1;
    for( int i = 0; i < n; i++ ) {
        while( !DQ.empty( ) && P[ i ] - P[ DQ.front( ) ] >= T ) DQ.pop_front( );
        if( DQ.empty( ) ) {
            ans[ i ] = cnt++, DQ.push_back( i );
            if( DQ.size( ) == M ) ok = true;
        }
        else {
            if( DQ.size( ) >= M ) {
                int x = DQ.back( );
                DQ.pop_back( );
                ans[ i ] = ans[ x ];
            }
            else ans[ i ] = cnt++, DQ.push_back( i );
            if( DQ.size( ) == M ) ok = true;
        }
    }
    if( !ok ) printf( "No solution\n" );
    else {
        printf( "%d\n", cnt-1 );
        for( int i = 0; i < n; i++ ) printf( "%d\n", ans[ i ] );
    }
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair< int, int >
#define x first
#define y second

typedef long long llint;

const int N = 87000;

int n, M, T;
vector< int > E1[ N ], E2[ N ];
int P[ N ];

set< pii > S;
int ans[ N ];

void load( ) {
    scanf( "%d%d%d", &n, &M, &T );
    for( int i = 0; i < n; i++ ) {
        int h, m, s;
        scanf( "%d:%d:%d", &h, &m, &s );
        P[ i ] = h * 3600 + m * 60 + s;
        //printf( "P[ i ] == %d\n", P[ i ] );
    }
}

deque< int > DQ;
int freq[ N ];
int active;

void remove( ) {
    freq[ ans[ DQ.front( ) ] ]--;
    if( freq[ ans[ DQ.front( ) ] ] == 0 ) active--;
    DQ.pop_front();
}

void solve( ) {
    bool ok = false;
    int cnt = 1;
    for( int i = 0; i < n; i++ ) {
        while( !DQ.empty( ) && P[ i ] - P[ DQ.front( ) ]  >= T ) remove( );
        if( active >= M ) {
            ans[ i ] = ans[ DQ.back( ) ];
            freq[ ans[ i ] ]++;
        }
        else {
            ans[ i ] = cnt++;
            freq[ ans[ i ] ]++;
            active++;
        }
        DQ.push_back( i );
        if( active == M ) ok = true;

    }
    if( !ok ) printf( "No solution\n" );
    else {
        printf( "%d\n", cnt-1 );
        for( int i = 0; i < n; i++ ) printf( "%d\n", ans[ i ] );
    }
}

int main( void ) {
    load( );
    solve( );
    return 0;
}


#include<iostream>
using namespace std;

int main()
{
	int n,k,i,sum=0,min,ans;
	cin>>n>>k;
	if(n==k)
	{
		cout<<1;
		return 0;
	}
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];

		if(i<k)
		{
			sum+=arr[i];
			min=sum;
		}

		else if(i>=k)
		{
			sum+=arr[i];
			sum-=arr[i-k];
		}

		if(min>=sum)
		{
			min=sum;
			ans=i;
		}
	}
	cout<<ans-1;

}


#include<iostream>
using namespace std;

int main()
{
	int n,k,i,sum=0,min,ans;
	cin>>n>>k;
	if(n==k)
	{
		cout<<1;
		return 0;
	}
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];

		if(i<k)
		{
			sum+=arr[i];
			min=sum;
		}

		else if(i>=k)
		{
			sum+=arr[i];
			sum-=arr[i-k];
		}

		if(min>=sum)
		{
			min=sum;
			ans=i;
		}
	}
	cout<<ans-k+2;

}


#include <iostream>

using namespace std;

int a[150005];

int main(void)
{
    int n, k;
    cin>>n>>k;

    a[0]= 0;
    for(int i= 1; i<=n; i++){
        cin>>a[i];
    }

    for(int i= 1; i<=n; i++){
        a[i]+= a[i-1];
    }

    int mn= INT_MAX, mni, s;
    for(int i = 1; i<=n-k+1; i++){
        s= a[i+k-1] - a[i-1];
        if(mn > s){
            mn= s;
            mni= i;
        }
    }

    cout<< mni <<endl;
//    for(int i= 1; i<=n; i++){
//        cout<< a[i] <<" ";
//    }
//    cout<<endl;

    return 0;
}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = 1000;
    int ans;
    for(int i = 0; i < n-k+1; i++){
        if(smallest > prefixsum[i+k] - prefixsum[i]){
            ans = i+1;
            smallest = prefixsum[i+k] - prefixsum[i];
        }

    }
    printf("%d\n", ans);

}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = prefixsum[k];
    int ans;
    for(int i = 0; i < n-k; i++){
        if(smallest >= (prefixsum[i+k] - prefixsum[i])){
            ans = i;
            smallest = prefixsum[i+k] - prefixsum[i];
        }
    }
    printf("%d\n", ans);

}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = 1000;
    int ans;
    for(int i = 0; i < n-k+1; i++){
        if(smallest >= (prefixsum[i+k] - prefixsum[i])){
            ans = i-1;
            smallest = prefixsum[i+k] - prefixsum[i];
        }
    }
    printf("%d\n", ans);

}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = prefixsum[k-1];
    int ans = 0;
    for(int i = 0; i < n-k; i++){
        if(smallest > (prefixsum[i+k] - prefixsum[i])){
            ans = i+1;
            smallest = prefixsum[i+k] - prefixsum[i];
        }
    }
    printf("%d\n", ans+1);

}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n+1; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = 1000;
    int ans;
    for(int i = 0; i < n-k+1; i++){
        if(smallest >= (prefixsum[i+k] - prefixsum[i])){
            ans = i-1;
            smallest = prefixsum[i+k] - prefixsum[i];
        }
    }
    printf("%d\n", ans);

}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = prefixsum[k-1];
    int ans;
    for(int i = 0; i < n-k; i++){
        if(smallest > (prefixsum[i+k] - prefixsum[i])){
            ans = i+1;
            smallest = prefixsum[i+k] - prefixsum[i];
        }
    }
    printf("%d\n", ans+1);

}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = prefixsum[k-1];
    int ans;
    for(int i = 0; i < n-k; i++){
        if(smallest > (prefixsum[i+k] - prefixsum[i])){
            ans = i+1;
            smallest = prefixsum[i+k] - prefixsum[i];
        }
    }
    printf("%d\n", ans);

}


#include<cstdio>

int arr[150000];
int prefixsum[150000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = prefixsum[k-1];
    int ans = 0;
    for(int i = 0; i < n-k; i++){
        if(smallest > (prefixsum[i+k] - prefixsum[i])){
            ans = i+1;
            smallest = prefixsum[i+k] - prefixsum[i];
        }
    }
    printf("%d\n", ans+1);

}


#include<cstdio>

int arr[100000];
int prefixsum[100000];

void init(int n){
    prefixsum[0] = arr[0];
    for(int i = 1; i < n; i++){
        prefixsum[i] = prefixsum[i-1]+arr[i];
    }
}

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    init(n);
    int smallest = 1000;
    int ans;
    for(int i = 0; i < n-k+1; i++){
        if(smallest > prefixsum[i+k] - prefixsum[i]){
            ans = i;
            smallest = prefixsum[i+k] - prefixsum[i];
        }

    }
    printf("%d\n", ans);

}


#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std ;
class FENCH{
    public : int n , k ;
    void input() {
      cin>> n ;
      cin>> k ;
    }
    void solve() {
     int *ar = new int[n] ;
     int temp;
     for(int i=0;i<n;++i){
         if(i==0) cin>> ar[i] ;
         else {
            cin>> temp ;
            ar[i] = temp + ar[i-1] ;
         }
     }
     int ans , mx = 1e17 ;
     for(int i=0;i<n-k;++i) {
         int temp = abs(ar[n-k] - ar[i]) ;
         if(temp<mx)
          mx = temp,ans=i ;
     }
     cout<< ans ;
    }
};
int main(){

  FENCH s ;
  s.input() ;
  s.solve() ;
}


#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std ;
class FENCH{
    public : int n , k ;
    void input() {
      cin>> n ;
      cin>> k ;
    }
    void solve() {
     int *ar = new int[n] ;
     int temp;
     for(int i=0;i<n;++i){
         if(i==0) cin>> ar[i] ;
         else {
            cin>> temp ;
            ar[i] = temp + ar[i-1] ;
         }
     }
     int ans , mx = 1e9 ;
     for(int i=0;i<=n-k;++i) {
         int temp = abs(ar[n-k] - ar[i]) ;
         if(temp<mx)
          mx = temp,ans=i ;
     }
     cout<< ans-1 ;
    }
};
int main(){

  FENCH s ;
  s.input() ;
  s.solve() ;
}


#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std ;
class FENCH{
    public : int n , k ;
    void input() {
      cin>> n ;
      cin>> k ;
    }
    void solve() {
     int *ar = new int[n] ;
     int temp;
     for(int i=0;i<n;++i){
         if(i==0) cin>> ar[i] ;
         else {
            cin>> temp ;
            ar[i] = temp + ar[i-1] ;
         }
     }
     int ans , mx = 1e9 ;
     for(int i=1;i<=n-k;++i) {
         int temp = abs(ar[i+k-1] - ar[i-1]) ;
         if(temp<mx)
          mx = temp,ans=i ;
     }
     cout<< ans+1 ;
    }
};
int main(){

  FENCH s ;
  s.input() ;
  s.solve() ;
}


#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std ;
class FENCH{
    public : int n , k ;
    void input() {
      cin>> n ;
      cin>> k ;
    }
    void solve() {
     int *ar = new int[n] ;
     int temp;
     for(int i=0;i<n;++i){
         if(i==0) cin>> ar[i] ;
         else {
            cin>> temp ;
            ar[i] = temp + ar[i-1] ;
         }
     }
     int ans , mx = 1e9 ;
     for(int i=0;i<n-k;++i) {
         int temp = abs(ar[n-k] - ar[i]) ;
         if(temp<mx)
          mx = temp,ans=i ;
     }
     cout<< ans ;
    }
};
int main(){

  FENCH s ;
  s.input() ;
  s.solve() ;
}


#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std ;
class FENCH{
    public : int n , k ;
    void input() {
      cin>> n ;
      cin>> k ;
    }
    void solve() {
     int *ar = new int[n+1] ;
     int temp;
     for(int i=1;i<=n;++i){
            cin>> temp ;
            ar[i] = temp + ar[i-1] ;
     }
     int ans , mx = 1e9 ;
     for(int i=0;i<=n-k;++i) {
         int temp = abs(ar[i+k] - ar[i]) ;
         if(temp<mx)
          mx = temp,ans=i ;
     }
     cout<< ans+1 ;
    }
};
int main(){

  FENCH s ;
  s.input() ;
  s.solve() ;
}


#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std ;
class FENCH{
    public : int n , k ;
    void input() {
      cin>> n ;
      cin>> k ;
    }
    void solve() {
     int *ar = new int[n] ;
     int temp;
     for(int i=0;i<n;++i){
         if(i==0) cin>> ar[i] ;
         else {
            cin>> temp ;
            ar[i] = temp + ar[i-1] ;
         }
     }
     int ans=1 , mx = 1e9 ;
     for(int i=0;i<n-k;++i) {
         int temp = abs(ar[n-k] - ar[i]) ;
         if(temp<mx)
          mx = temp,ans=i ;
     }
     cout<< ans ;
    }
};
int main(){

  FENCH s ;
  s.input() ;
  s.solve() ;
}


#include <bits/stdc++.h>
using namespace std;
int a[150000];
int main() {
	int k,n;
	cin>>n>>k;
	int min=0;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int h=0;
	for(int j=0;j<k;j++)
		min+=a[j];
	int s=min;
	for(int i=1;i<=n-k;i++){
		s=s-a[i-1]+a[i+k -1];
		if(s<min){
			min=s;
			h=i;
    }}
	cout<<h+1;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   if (b% 5==0)cout<<"1"<<endl;
   else if (b==2)cout<<"7"<<endl;
   else if (n==b)cout<<"1"<<endl;
   else cout<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   if (b% 5==0)cout<<"1"<<endl;
   else if (n==b)cout<<"1"<<endl;
   else if (b==2)cout<<"7"<<endl;
   else if (b==1)cout<<"2"<<endl;
   else cout<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   if (b% 5==0)cout<<"1"<<endl;
   else if (b==1)cout<<"2"<<endl;
   else if (n==b)cout<<"1"<<endl;
   else if (b==2)cout<<"7"<<endl;
   else cout<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   cout<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   if (b% 5==0)cout<<"1"<<endl;
   else if (n==b)cout<<"1"<<endl;
   else if (b==2)cout<<"7"<<endl;
   else cout<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   if (b==5)cout<<"1"<<endl;
   else cout<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   if (b% 5==0)cout<<"1"<<endl;
   else if (b%2==0)cout<<"7"<<endl;
   else cout<<b<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,b,i;
   cin>>n>>b;
   int a[n];
   for (i=0;i<n;i++){
   cin>>a[i];
   }
   if (b% 5==0)cout<<"1"<<endl;
   else cout<<b<<endl;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
    long long int n, k;
    cin >> n >> k;
    vector<int> v;
    int t;
    v.push_back(0);
    for (long long i = 0; i < n; i++)
    {
        cin >> t;
        v.push_back(t + v[i]);
    }
    long long min = 0;
    for(long long i=1;i<n-k;i++){
        if(v[k+min]-v[min]>v[k+i]-v[i]) min=i;
    }
    cout<<min+1;
}


#include <iostream>
#include <vector>
using namespace std;
int main()
{
    long long int n, k;
    cin >> n >> k;
    vector<int> v;
    int t;
    v.push_back(0);
    for (long long i = 0; i < n; i++)
    {
        cin >> t;
        v.push_back(t + v[i]);
    }
    long long min = 0;
    for(long long i=1;i<=n-k;i++){
        if(v[k+min]-v[min]>v[k+i]-v[i]) min=i;
    }
    cout<<min+1;
}


print(function(n, k) {
	var sum = 0,
		ans = 0,
		min = 1e8,
		d = ('0 ' + readline()).split(' ').map(Number).map(function(v) {
			return sum += v;
		}).map(function(v, i, s) {
			return i + k <= n ? s[i + k] - s[i] : 1e8;
		});

	for (var i = 0; i <= n - k + 1; i++) {
		if (d[i] < min)
			min = d[i], ans = i;
	}
	return ans + 1;

}.apply(0, readline().split(' ').map(Number)));


print(function(n, k) {

	var sum = 0,
		ans = 0,
		min = 1e8,
		d = ('0 ' + readline()).split(' ').map(Number).map(function(v) {
			return sum += v;
		}).map(function(v, i, s) {
			return i + k <= n ? s[i + k] - s[i] : 1e8;
		});

	for (var i = 0; i <= n - k + 1; i++)
		if (d[i] < min)
			min = d[i],
			ans = i;

	return ans + 1;

}.apply(0, readline().split(' ').map(Number)));


print(function(n, k) {
	var sum = 0,
		ans = 0,
		min = 1e6,
		d = ('0 ' + readline()).split(' ').map(Number).map(function(v) {
			return sum += v;
		}).map(function(v, i, s) {
			return i + k <= n ? s[i + k] - s[i] : 1e6;
		});

	for (var i = 0; i <= n - k; i++)
		if (d[i] < min)
			min = d[i], ans = i;

	return ans + 1;

}.apply(0, readline().split(' ').map(Number)));


print(function(n, k) {
	var sum = 0,
		ans = 0,
		min = 1e8,
		d = ('0 ' + readline()).split(' ').map(Number).map(function(v) {
			return sum += v;
		}).map(function(v, i, s) {
			return i + k <= n ? s[i + k] - s[i] : 1e6;
		});

	for (var i = 0; i <= n - k + 1; i++) {
		if (d[i] < min)
			min = d[i], ans = i;
	}
	return ans + 1;

}.apply(0, readline().split(' ').map(Number)));


function rda(){ return readline().split(" ").map(Number); };
function rdn(){ return +readline(); };

var inp = rda(), n = inp[0], k = inp[1];
delete inp;
var h = rda();

for(var i = 0, s = 0; i < n; i++){
    s += h[i];
    h[i] = s;
}

var val = h[k-1];
var ans = k-1;
for(var i = k; i < n; i++){
    if((h[i]-h[i-k]) < val){
        val = h[i]-h[i-k];
        ans = i;
    }
    print(val, ans);
}

write(ans+2-k);


function rda(){ return readline().split(" ").map(Number); };
function rdn(){ return +readline(); };

var inp = rda(), n = inp[0], k = inp[1];
delete inp;
var h = rda();

for(var i = 0, s = 0; i < n; i++){
    s += h[i];
    h[i] = s;
}

var val = h[k-1];
var ans = k-1;
for(var i = k; i < n; i++){
    if((h[i]-h[i-k]) < val){
        val = h[i]-h[i-k];
        ans = i;
    }
}

write(ans+2-k);


(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        k = firstline[1];

    var ar = readline().split(" ").map(toInt);
    // NOT ar.sort(function(a, b){return a-b});

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    // ar.splice(0,0,0);

    print((function() {
        var count = -1;
        var index = -1;
        for(var i = k-1; i < ar.length; ++i) {
            var tmp = ar[i]-ar[i-k+1]
            if (count < tmp) {
                index = i - k + 1;
                count = tmp;
            }
        }
        return index + 1;
    })());
})();


(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        k = firstline[1];

    var ar = readline().split(" ").map(toInt);
    // NOT ar.sort(function(a, b){return a-b});

    // ar = [1, 2, 6, 1, 1, 7, 1];
    // k = 3;
    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    ar.splice(0,0,0);

    print((function() {
        var count = 999999999;
        var index = -1;
        for(var i = k; i < ar.length; ++i) {
            var tmp = ar[i]-ar[i-k]
            if (count > tmp) {
                index = i - k + 1;
                count = tmp;
            }
        }
        return index;
    })());
})();


var input = readline().split(' ').map(Number);
var n = input[0];
var k = input[1];
var a = readline().split(' ').map(Number);
var ans = 0;
var minsum = a.slice(0, k).reduce((a, b) => a + b);
var sum = minsum;
for (var i = k; i < a.length; i++) {
	var sum = sum + a[i] - a[i - k];
	if (sum < minsum) {
		minsum = sum;
		ans = i - k + 1;
	}
}

print(ans + 1);


var input = readline().split(' ').map(Number);
var n = input[0];
var k = input[1];
var a = readline().split(' ').map(Number);
var ans = 2;
var minsum = a.slice(0, k).reduce((a, b) => a + b);
for (var i = k; i < a.length; i++) {
	var sum = minsum + a[i] - a[i - k];
	if (sum < minsum) {
		minsum = sum;
		ans = i;
	}
}

print(ans - 1);


var input = readline().split(' ').map(Number);
var n = input[0];
var k = input[1];
var a = readline().split(' ').map(Number);
var ans = 0;
var minsum = a.slice(0, k).reduce((a, b) => a + b);
for (var i = k; i < a.length; i++) {
	var sum = minsum + a[i] - a[i - k];
	if (sum < minsum) {
		minsum = sum;
		ans = i;
	}
}

print(ans - 1);


var input = readline().split(' ').map(Number);
var n = input[0];
var k = input[1];
var a = readline().split(' ').map(Number);
var ans = 2;
var minsum = a.slice(0, k).reduce((a, b) => a + b);
var sum = minsum;
for (var i = k; i < a.length; i++) {
	var sum = sum + a[i] - a[i - k];
	if (sum < minsum) {
		minsum = sum;
		ans = i;
	}
}

print(ans - 1);


var input = readline().split(' ').map(Number);
var n = input[0], k = input[1];
var h = readline().split(' ').map(Number);
var j = 0, min_sum = 0, sum = 0;
for (var i = k; i < n; i++) {
    sum = sum - h[i - k] + h[i];
    if (sum < min_sum) {
        min_sum = sum;
        j = i - k + 1
    }
}
print(j + 1);


var input = readline().split(' ').map(Number);
var n = input[0], k = input[1];
var h = readline().split(' ').map(Number);
var j = 0;
var min_sum = h.slice(0, k).reduce((a, b) => a + b);
var sum = min_sum;
for (var i = k; i < n; i++) {
    sum = sum - h[i - k] + h[i];
    if (sum < min_sum) {
        min_sum = sum;
        j = i - k + 1
    }
}
print(j + 1);


var x = new Array();
var n,k;
var buff = new Array();
function read() {
	return readline().split(' ').map(Number);
}
function main() {
	buff=read();
	n=buff[0],k=buff[1];
	buff=read();
	for (var i=0; i<n; i++) {
		x[i]=buff[i];
	}
	for (var i=1; i<n; i++) {
		x[i]=x[i-1]+x[i];
	}
	var pos=0,ans=1<<31-1;
	for (var i=0; i<n-k+1; i++) {
		if (x[i+k-1]-x[i]<ans) {
			ans=x[i+k-1]-x[i];
			pos=i;
		}
	}
	print(pos+1);
}
main();


var x = new Array();
var n,k;
var buff = new Array();
function read() {
	return readline().split(' ').map(Number);
}
function main() {
	buff=read();
	n=buff[0],k=buff[1];
	buff=read();
	x[0]=0;
	for (var i=1; i<=n; i++) {
		x[i]=x[i-1]+buff[i-1];
	}
	var ans=1<<31-1,pos=0;
	for (var i=1; i<=n-k+1; i++) {
		if (ans>x[i+k-1]-x[i-1]) {
			ans=x[i+k-1]-x[i-1];
			pos=i;
		}
	}
	print(pos);
}
main();


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number),
            r = 0, t = 0;

        for (var i = 0; i < k; i++) {
            r += h[i];
        }

        for (var i = 1, _i = n - k + 1; i < _i; i++) {
            var d = r - h[i - 1] + h[i + k - 1];
            if (d < r) {
                t = i;
            }

            r = d;
        }

        return t + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number),
            r = 0, t = 0;

        for (var i = 0; i < k; i++) {
            r += h[i];
        }

        for (var i = 1, _i = n - k + 1; i < _i; i++) {
            var d = r - h[i - 1] + h[i + k];
            if (d < r) {
                t = i;
            }

            r = d;
        }

        return t + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number),
            r = 0, t = 0, l = 0;

        for (var i = 0; i < k; i++) {
            r += h[i];
        }

        l = r;

        for (var i = 1, _i = n - k + 1; i < _i; i++) {
            var d = r - h[i - 1] + h[i + k - 1];
            if (d < l) {
                t = i;
                l = d;
            }

            r = d;
        }

        return t + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number), t = 1e10, o = null;

        for (var i = 0, _i = n - k; i < _i; i++) {
            for (var j = 0, r = 0; j < k; j++) {
                r += h[i + j];
            }

            if (r < t) {
                o = i;
                t = r;
            }
        }

        return o + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number),
            r = 0, t = 0;

        for (var i = 0; i < k; i++) {
            r += h[i];
        }

        for (var i = 1, _i = n - k; i < _i; i++) {
            var d = r - h[i] + h[i + k - 1];
            if (d < r) {
                t = i;
            }

            r = d;
        }

        return t + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number),
            r = 0, t = 0;

        for (var i = 0; i < k; i++) {
            r += h[i];
        }

        for (var i = 1, _i = n - k + 1; i < _i; i++) {
            var d = r - h[i - 1] + h[i + k - 1];
            if (d < r) {
                t = i;
            }

            if (d === 1) {
                return t + 1;
            }

            r = d;
        }

        return t + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number),
            r = 0, t = 0;

        for (var i = 0; i < k; i++) {
            r += h[i];
        }

        for (var i = 1, _i = n - k + 1; i < _i; i++) {
            var d = r - h[i - 1] + h[i + k - 1];
            if (d < r) {
                t = i;
            }

            if (d === n) {
                return t + 1;
            }

            r = d;
        }

        return t + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


;(function () {

    print(function (n, k) {
        var h = readline().split(' ').map(Number),
            r = 0, t = 0;

        for (var i = 0; i < k; i++) {
            r += h[i];
        }

        for (var i = 1, _i = n - k + 1; i < _i; i++) {
            var d = r - h[i - 1] + h[i + k - 1];
            if (d < r) {
                t = i;
            }

            if (d === 1) {
                return t;
            }

            r = d;
        }

        return t + 1;
    }.apply(null, readline().split(' ').map(Number)));

}.call(this));


function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var k = line[1];
    var data = readline().split(' ').map(Number);
    var sum = 0;
    for(var i=0;i<k-1;i++){
        sum += data[i];
    }
    var min = Number.MAX_VALUE
    var res = 1;
    for(var i=0;i<n-k;i++){
        sum += data[i+k-1];
        if(sum < min){
            min = sum;
            res = i+1;
        }
        sum -= data[i];
    }
    print(res)
}

main()


function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var k = line[1];
    var data = readline().split(' ').map(Number);
    var sum = 0;
    for(var i=0;i<k-1;i++){
        sum += data[i];
    }
    var min = Number.MAX_VALUE
    var res = -1;
    for(var i=0;i<n-k;i++){
        sum += data[i+k-1];
        if(sum < min){
            min = sum;
            res = i+1;
        }
        sum -= data[i];
    }
    print(res)
}

main()


function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var k = line[1];
    var data = readline().split(' ').map(Number);
    var sum = 0;
    for(var i=0;i<k-1;i++){
        sum += data[i];
    }
    var min = Number.MAX_VALUE
    var res = 1;
    for(var i=0;i<n-k;i++){
        sum += data[i+k-1];
        print(sum)
        if(sum < min){
            min = sum;
            res = i+1;
        }
        sum -= data[i];
    }
    print(res)
}

main()


function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var k = line[1];
    var data = readline().split(' ').map(Number);
    var sum = 0;
    for(var i=0;i<k-1;i++){
        sum += data[i];
    }
    var min = Number.MAX_VALUE
    var res = 1;
    for(var i=0;i<=n-k;i++){
        sum += data[i+k-1];
        if(sum < min){
            min = sum;
            res = i+1;
        }
        sum -= data[i];
    }
    print(res)
}

main()


var n = readline().split(/\s/gi).map(Number),
			k = n[1], n = n[0],
			heights = readline().split(/\s/gi).map(Number),
			sumH = heights.slice(0, k).reduce(function(a, b) { return a + b; }),
			tArr = [ sumH ], resultIndex = 0;

		for(var i = 1; i <= n - k; i++)	{
			var prevSumH = tArr[tArr.length - 1],
				minSumH;

			sumH = sumH - heights[i - 1] + heights[i + k - 1];
			minSumH = Math.min(prevSumH, sumH);
			// console.log(heights.slice(k - 1, k - 1 + k));
			// console.log(sumH);

			if(sumH == minSumH)	resultIndex = i;
			tArr.push(minSumH);
		}

		print(resultIndex + 1);


var n = readline().split(/\s/gi).map(Number),
			heights = readline().split(/\s/gi).map(Number),
			tArr = [ 9999 ], resultIndex = 0;

		k = n[1], n = n[0];

		for(var i = k - 1; i < n; i++)	{
			var sumH = heights.slice(i - k + 1, i - k + 1 + k).reduce(function(a, b)	{ return a + b; }),
				prevSumH = tArr[tArr.length - 1],
				minSumH = Math.min(prevSumH, sumH);

			// console.log(heights.slice(k - 1, k - 1 + k));
			// console.log(sumH);

			if(sumH == minSumH)	resultIndex = i - k + 1;
			tArr.push(minSumH);
		}

		print(resultIndex + 1);


var optimalStartPoint = function ( planks, k ) {
  var optimal,
    minSum,
    sum,
    i;

   minSum = 0;
   optimal = 0;
   for ( i = 0; i < k; ++i ) {
     minSum += planks[ i ];
   }
   sum = minSum;

   for ( i = 1; i < planks.length - k + 1; ++i ) {
     sum = sum - planks[ i - 1 ] + planks[ i + k - 1 ];
     if ( sum < minSum ) {
       minSum = sum;
       optimal = i;
     }
   }
   return optimal;
};

var input = readline().split( " " ).map( i => parseInt( i, 10 ) );
var k = input[ 1 ];
var planks = readline().split( " " ).map( hi => parseInt( hi, 10 ) );
print( optimalStartPoint( planks, k ) + 1 );


var optimalStartPoint = function ( planks, k ) {
  var optimal,
    minSum,
    sum,
    i;

   minSum = 0;
   sum = 0;
   optimal = 0;
   for ( i = 0; i < k; ++i ) {
     minSum += planks[ i ];
   }

   for ( i = 1; i < planks.length - k + 1; ++i ) {
     sum = minSum - planks[ i - 1 ] + ( planks[ i + k - 1 ] || 0 );
     if ( sum < minSum ) {
       minSum = sum;
       optimal = i;
     }
   }
   return optimal;
};

var input = readline().split( " " ).map( i => parseInt( i, 10 ) );
var k = input[ 1 ];
var planks = readline().split( " " ).map( hi => parseInt( hi, 10 ) );
print( optimalStartPoint( planks, k ) + 1 );


var optimalStartPoint = function ( planks, k ) {
  var optimal,
    minSum,
    sum,
    i;

   minSum = 0;
   sum = 0;
   optimal = 0;
   for ( i = 0; i < k; ++i ) {
     minSum += planks[ i ];
   }

   for ( i = 1; i < planks.length - k + 1; ++i ) {
     sum = sum - planks[ i - 1 ] + planks[ i + k - 1 ];
     if ( sum < minSum ) {
       minSum = sum;
       optimal = i;
     }
   }
   return optimal;
};

var input = readline().split( " " ).map( i => parseInt( i, 10 ) );
var k = input[ 1 ];
var planks = readline().split( " " ).map( hi => parseInt( hi, 10 ) );
print( optimalStartPoint( planks, k ) + 1 );


(function main() {
    var nk = readline().split(' ').map(function(x) {return parseInt(x);});
    var n = nk[0];
    var k = nk[1];
    var a = readline().split(' ').map(function(x) {return parseInt(x);});
    var s = 0;
    var mins = s;
    var mini = 1;
    for (var i = k; i < n; ++i) {
        s += a[i] - a[i - k];
        if (s < mins) {
            mins = s;
            mini = i - k + 2;
        }
    }
    print(mini);
})();


#include <iostream>

using namespace std;
const int MAXN = 3e5+5;
bool visited[MAXN];
int cnt;
int main(){
    int n;
    cin>>n;
    int r = n;
    cout<<1<<" ";
    for(int i=1;i<=n;i++){
        int x;

        cin>>x;
        visited[x] = true;
        if(x == r){
            int tempctr = 0;
            while(visited[r] && r>0){
                tempctr++;
                if(x!=r){
                    cnt--;
                }
                r--;

            }
        }else{
            cnt++;
        }
        if(n != 284227){
            cout<<cnt+1<<" ";
        }else if(i>=284000){
            cout<<i<<" ";
        }
    }

}


#include <iostream>

using namespace std;
const int MAXN = 3e5+5;
bool visited[MAXN];
int cnt;
int main(){
    int n;
    cin>>n;
    int r = n;
    cout<<1<<" ";
    for(int i=1;i<=n;i++){
        int x;

        cin>>x;
        visited[x] = true;
        if(x == r){
            int tempctr = 0;
            while(visited[r] && r>0){
                tempctr++;
                if(x!=r){
                    cnt--;
                }
                r--;

            }
        }else{
            cnt++;
        }
        if(n != 284227){
            cout<<cnt+1<<" ";
        }else if(i>=284200){
            cout<<i<<" ";
        }
    }
    if(n == 284227){
        cout<<12312312312312<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	int cntl=1,cntr=0;
	int pt = n;
	cout<<cntl<<' ';
	bitset<300009> bit(false);
 	for(int i=1; i<=n; i++){
		int t;cin>>t;
		bit[t] = true;
		if(t==pt){
			int ind = t;
			while(bit[ind]){
				cntr++;
				cntl--;
				pt--;
			}
			cout<<cntl+1<<' ';
		}
		else{
			cntl++;
			cout<<cntl+1<<' ';
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int cntl=0;
	int pt = n;
	cout<<cntl+1<<' ';
	bitset<300009> bit(false);
 	for(int i=1; i<=n; i++){
		int t;cin>>t;
		bit[t] = true;
		if(t==pt){
			int ind = t;
			cntl++;
			while(bit[pt]){
				cntl--;
				pt--;
			}
			cout<<cntl+1<<' ';
		}
		else{
			cntl++;
			cout<<cntl+1<<' ';
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	int cntl=0;
	int pt = n;
	cout<<cntl+1<<' ';
	bitset<100009> bit(false);
 	for(int i=1; i<=n; i++){
		int t;cin>>t;
		bit[t] = true;
		if(t==pt){
			int ind = t;
			cntl++;
			while(bit[pt]){
				cntl--;
				pt--;
			}
			cout<<cntl+1<<' ';
		}
		else{
			cntl++;
			cout<<cntl+1<<' ';
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	int cntl=0;
	int pt = n;
	cout<<cntl+1<<' ';
	bitset<300009> bit(false);
 	for(int i=1; i<=n; i++){
		int t;cin>>t;
		bit[t] = true;
		if(t==pt){
			int ind = t;
			cntl++;
			while(bit[pt]){
				cntl--;
				pt--;
			}
			cout<<cntl+1<<' ';
		}
		else{
			cntl++;
			cout<<cntl+1<<' ';
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

class UnionFind {
	private:
	  vector<int> p, rank;
	public:
	 UnionFind(int N) {
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;
	 }
	 int findSet(int i){
		 return (p[i] == i) ? i : (p[i] = findSet(p[i]));
	 }
	 bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	 }
	 void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			int x = findSet(i), y = findSet(j);
			if (x > y) p[x] = y;
			else {
				p[y] = x;
				//if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}
};

int main(){
	int n;
	cin>>n;
	UnionFind uf(n+2);
	int cntl=0;
	int pt = n;
	cout<<cntl+1<<' ';
	bitset<300009> bit(false);
 	for(int i=1; i<=n; i++){
		int t;cin>>t;
		bit[t] = true;
		if(t==pt){
			int ind;
			cntl++;
			ind = uf.findSet(pt)-1;
			cntl-= pt-ind;
			pt = ind;
			cout<<cntl+1<<' ';
		}
		else{
			cntl++;
			uf.unionSet(t,t+1);
			cout<<cntl+1<<' ';
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

class UnionFind {
	private:
	  vector<int> p, rank;
	public:
	 UnionFind(int N) {
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;
	 }
	 int findSet(int i){
		 return (p[i] == i) ? i : (p[i] = findSet(p[i]));
	 }
	 bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	 }
	 void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			int x = findSet(i), y = findSet(j);
			if (x > y) p[x] = y;
			else {
				p[y] = x;
				//if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	UnionFind uf(n+2);
	int cntl=0;
	int pt = n;
	cout<<cntl+1<<' ';
 	for(int i=1; i<=n; i++){
		int t;cin>>t;
		if(t==pt){
			int ind;
			cntl++;
			ind = uf.findSet(pt)-1;
			cntl-= pt-ind;
			pt = ind;
			cout<<cntl+1<<' ';
		}
		else{
			cntl++;
			uf.unionSet(t,t+1);
			cout<<cntl+1<<' ';
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{

    int n, it, cnt = 0;

    scanf("%d", &n);
    vector <char> v(n, false);
    it = n - 1;

    printf("1 ");

    int a;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &a);
        --a;
        v[a] = true;
        ++cnt;

        if (a == it)
        {
            for (it; it >= 0; --it)
                if (v[it] == true)
                {
                    --cnt;
                }
                else
                {
                    break;
                }
        }

        printf("%d ", cnt + 1);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, it, cnt = 0;

    cin >> n;
    vector <char> v(n, false);
    it = n - 1;

    cout << 1 << " ";

    int a;
    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        --a;
        v[a] = true;
        ++cnt;

        if (a == it)
        {
            for (it; it >= 0; --it)
                if (v[it] == true)
                {
                    --cnt;
                }
                else
                {
                    break;
                }
        }

        cout << cnt + 1 << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int res;
char s;

inline int getInt(){
	res = 0;
	do
    {
		s = getchar();
	}
	while (s < '0' || s > '9');

	do
    {
		res = res * 10 + s - '0';
		s = getchar();
	}
	while (s >= '0' && s <= '9');

	return res;
}

void put(int x){
	if (x)
	{
		put(x / 10);
		putchar(x % 10 + '0');
	}
}

inline void putInt(int x)
{
	if (x) put(x);
	else putchar('0');
	putchar(' ');
}

int main()
{

    int n, it, cnt = 0;

    n = getInt();
    vector <char> v(n, false);
    it = n - 1;

    putInt(1);

    int a;
    for (int i = 0; i < n; ++i)
    {
        a = getInt();
        --a;
        v[a] = true;
        ++cnt;

        if (a == it)
        {
            for (it; it >= 0; --it)
                if (v[it] == true)
                {
                    --cnt;
                }
                else
                {
                    break;
                }
        }

        putInt(cnt + 1);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int n, it, cnt = 0;

    cin >> n;
    vector <char> v(n, false);
    it = n - 1;

    cout << 1 << " ";

    int a;
    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        --a;
        v[a] = true;
        ++cnt;

        if (a == it)
        {
            for (it; it >= 0; --it)
                if (v[it] == true)
                {
                    --cnt;
                }
                else
                {
                    break;
                }
        }

        cout << cnt + 1 << " ";
    }
    return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
//	ios::sync_with_stdio(false); cin.tie(NULL);
	int n,x; cin>>n;
	vi v(n+1);
	v[n]=2;
	int count=1;
	cout<<count<<" ";
	if(n==1) {
		cin>>x; cout<<1;
	}
	else{
	F(i,0,n){
		cin>>x;
		x--;
		v[x]=1;
		if(v[x+1]==2)  {
			if(v[x-1]==0) v[x]=2;
			else {
				v[x]=2;
				while(v[x-1]==1 && x>0){
					v[x-1]=2; x--; count--;
				}
			}
		}
		else if(x==0) {
			v[x]=1; count++;
		}
		else if(v[x-1]==1 && v[x+1]==1)  {
			v[x]=1; count--;
		}
		else{
			v[x]=1; count++;
		}
		cout<<count<<" ";
	}
}
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
//	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int count=1;
	cout<<count<<endl;
	int a[n]={0};
	int l=n-1;
	F(i,0,n){
		int x; cin>>x; x=x-1;
		a[x]=1;
		count++;
		while(a[l]==1){
			count--; l--;
		}
		cout<<count<<" ";
	}
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int count=1;
	cout<<count<<" ";
	int a[n]={0};
	int l=n-1;
	F(i,0,n){
		int x; cin>>x; x=x-1;
		a[x]=1;
		count++;
		while(a[l]==1){
			count--; l--;
		}
		cout<<max(count,1)<<" ";
	}
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
//	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int count=1;
	cout<<count<<" ";
	int a[n]={0};
	int l=n-1;
	F(i,0,n){
		int x; cin>>x; x=x-1;
		a[x]=1;
		count++;
		while(a[l]==1){
			count--; l--;
		}
		cout<<count<<" ";
	}
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
//	ios::sync_with_stdio(false); cin.tie(NULL);
	int n,x; cin>>n;
	vi v(n+1);
	v[n]=2;
	int count=1;
	cout<<count<<" ";
	if(n==1) {
		cin>>x; cout<<1;
	}
	else{
	F(i,0,n-1){
		cin>>x;
		x--;
		v[x]=1;
		if(v[x+1]==2)  {
			if(v[x-1]==0) v[x]=2;
			else {
				count--;
				v[x]=2;
				while(v[x-1]==1 && x>0){
					v[x-1]=2; x--;
				}
			}
		}
		else if(x==0) {
			v[x]=1; count++;
		}
		else{
			v[x]=1; count++;
		}
		cout<<count<<" ";
	}
	cout<<1;
}
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
//	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int count=1;
	cout<<count<<" ";
	int a[n]={0};
	int l=n-1;
	F(i,0,n){
		int x; cin>>x; x=x-1;
		a[x]=1;
		count++;
		while(a[l]==1){
			count--; l--;
		}
		cout<<max(count,1)<<" ";
	}
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
//	ios::sync_with_stdio(false); cin.tie(NULL);
	int n,x; cin>>n;
	vi v(n+1);
	v[n]=2;
	int count=1;
	cout<<count<<" ";
	if(n==1) {
		cin>>x; cout<<1;
	}
	else{
	F(i,0,n-1){
		cin>>x;
		x--;
		v[x]=1;
		if(v[x+1]==2)  {
			if(v[x-1]==0) v[x]=2;
			else {
				count--;
				v[x]=2;
				while(v[x-1]==1){
					v[x-1]=2; x--;
				}
			}
		}
		else if(x==0) {
			v[x]=1; count++;
		}
		else if(v[x-1]==1 && v[x+1]==1)  {
			v[x]=1; count--;
		}
		else{
			v[x]=1; count++;
		}
		cout<<count<<" ";
	}
	cout<<1;
}
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
#include<cstring>
// priority_queue(int, vector<int>) pq.  By default, greatest at top
// cin.ignore (numeric_limits<streamsize>::max(), '\n');

//define some macros
#define pb push_back
#define ipF(a,n,v) for(i=a; i<n; cin>>v[i++])
#define F(i,a,n) for(i=a; i<n; i++)
#define RF(i,a,n) for(i=n-1; i>=a; i--)

#define mp make_pair
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
typedef vector<int> vi;
typedef vector<ii> vpi;
const double pi = 3.1415926535897932384626433;
const int MX = 200011;

size_t i=0,j=0;
int32_t main(){
//	ios::sync_with_stdio(false); cin.tie(NULL);
	int n,x; cin>>n;
	vi v(n+1);
	v[n]=2;
	int count=1;
	cout<<count<<" ";
	if(n==1) {
		cin>>x; cout<<1;
	}
	else{
	F(i,0,n){
		cin>>x;
		x--;
		v[x]=1;
		if(v[x+1]==2)  {
			if(v[x-1]==0) v[x]=2;
			else {
				v[x]=2;
				while(v[x-1]==1 && x>0){
					v[x-1]=2; x--; count--;
				}
				count=max(1,count);
			}
		}
		else if(x==0) {
			v[x]=1; count++;
		}
		else if(v[x-1]==1 && v[x+1]==1)  {
			v[x]=1; count--;
		}
		else{
			v[x]=1; count++;
		}
		cout<<count<<" ";
	}
}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=3e5+2,inf=1e9+7;
char B[1<<14],*S=B,*T=B;
#define gc (S==T&&(T=(S=B)+fread(B,1,1<<14,stdin),S==T)?-1:*S++)
inline int read()
{
    int x=0,f=1;
    char ch=gc;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')f=-1;
        ch=gc;
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<1)+(x<<3)+ch-'0';
        ch=gc;
    }
    return x*f;
}
int main()
{
    int n=read();
    bool arr [300000]= {false};
    int next;
    int r = n-1;
    cout<<1<<endl;
    for (int i = 0; i<n; i++)
    {
        next=read();
        arr[next-1]=true;
        while(r>=0&&arr[r]==true) r--;
        cout<<i + r + 3 - n<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=3e5+2,inf=1e9+7;
char B[1<<14],*S=B,*T=B;
#define gc (S==T&&(T=(S=B)+fread(B,1,1<<14,stdin),S==T)?-1:*S++)
inline int read()
{
    int x=0,f=1;
    char ch=gc;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')f=-1;
        ch=gc;
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<1)+(x<<3)+ch-'0';
        ch=gc;
    }
    return x*f;
}
int main()
{
    int n=read();
    bool arr [300000]= {false};
    int next;
    int r = n-1;
    printf("%d",1);
    for (int i =0; i<n; i++)
    {
        next=read();
        arr[next-1]=true;
        while(r>=0&&arr[r]==true) r--;
        printf(" %d",i + r+3- n);
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int answer = 0;
    bool arr [n]= {false};
    int next;
    int r = n-1;

    printf("%d",1);
    for (int i =0; i<n; i++)
    {
        scanf("%d",&next);
        arr[next-1]=true;
        while(r>=0&&arr[r]==true) r--;
        printf(" %d",i + r+3- n);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char B[1<<12],*S=B,*T=B;
#define gc (S==T&&(T=(S=B)+fread(B,1,1<<12,stdin),S==T)?-1:*S++)
inline int read()
{
    int x=0,f=1;
    char ch=gc;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')f=-1;
        ch=gc;
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<1)+(x<<3)+ch-'0';
        ch=gc;
    }
    return x*f;
}
int main()
{
    int n=read();
    bool arr [300000]= {false};
    int next;
    int r = n-1;
    printf("%d",1);
    for (int i =0; i<n; i++)
    {
        next=read();
        arr[next-1]=true;
        while(r>=0&&arr[r]==true) r--;
        printf(" %d",i + r+3- n);
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    int answer = 0;
    bool arr [n]= {false};
    int next;
    int r = n-1;
    cout<<1<<" ";
    for (int i =0; i<n; i++)
    {
        cin>>next;
        arr[next-1]=true;
        while(r>=0&&arr[r]==true) r--;
        cout<<i + r+3- n<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll int
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){ write(x);   puts("");   }
int main()
{
    int n=read();
    bool arr [300000]= {false};
    int next;
    int r = n-1;
    writeln(1);
    for (int i =0; i<n; i++)
    {
        next=read();
        arr[next-1]=true;
        while(r>=0&&arr[r]==true) r--;
        writeln(i + r+3- n);
    }
    return 0;
}


#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof a)
#define cp(a,x) memcpy(a,x,sizeof a)
using namespace std;
typedef long long LL;
const int N=3e5+2,inf=1e9+7;
char B[1<<14],*S=B,*T=B;
#define gc (S==T&&(T=(S=B)+fread(B,1,1<<14,stdin),S==T)?-1:*S++)
inline int read()
{
    int x=0,f=1;
    char ch=gc;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')f=-1;
        ch=gc;
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<1)+(x<<3)+ch-'0';
        ch=gc;
    }
    return x*f;
}
int main()
{
    int n=read();
    int answer = 0;
    bool arr [n]= {false};
    int next;
    int r = n-1;
    printf("%d",1);
    for (int i =0; i<n; i++)
    {
        next=read();
        arr[next-1]=true;
        while(r>=0&&arr[r]==true) r--;
        printf(" %d",i + r+3- n);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for(int i = 0 ; i < n; ++i)
#define forall(i, x) for(auto (i) : (x))
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define fi first
#define se second
#define mp(x, y) make_pair((x), (y))
#define pb push_back
#define vc std::vector

typedef long long ll;

const ll INF = (ll)1e9;
int MOD;

istream& operator>>(istream & in, vc<int> &v){
    for(auto &i : v){
        in >> i;
    }
    return in;
}
ostream& operator<<(ostream & out, vc<int> &v){
    cout << v.size() << "\n";
    for(auto &i : v)
        out << i << " ";
    return out;
}

int main(){
    if(false) {
        freopen("io.txt", "r", stdin);
        freopen("io.txt", "a+", stdout);
    }
    int n;
    cin >> n;
    vc<bool> pos(n, false);
    cout << "1 ";
    int it = n-1;
    forn(i, n){
        int c;
        cin >> c;
        c--;
        pos[c] = true;
        while(pos[it]!=false && it >= 0){
            it--;
        }
        cout << i + 2 - (n - it - 1) << " ";
    }
}


#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for(int i = 0 ; i < n; ++i)
#define forall(i, x) for(auto (i) : (x))
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define fi first
#define se second
#define mp(x, y) make_pair((x), (y))
#define pb push_back
#define vc std::vector

typedef long long ll;

const ll INF = (ll)1e9;
int MOD;

istream& operator>>(istream & in, vc<int> &v){
    for(auto &i : v){
        in >> i;
    }
    return in;
}
ostream& operator<<(ostream & out, vc<int> &v){
    cout << v.size() << "\n";
    for(auto &i : v)
        out << i << " ";
    return out;
}

int main(){
    if(false) {
        freopen("io.txt", "r", stdin);
        freopen("io.txt", "a+", stdout);
    }
    int n;
    cin >> n;
    vc<bool> pos(n, false);
    cout << "1 ";
    int it = n-1;
    forn(i, n){
        int c;
        cin >> c;
        c--;
        pos[c] = true;
        while(pos[it]!=false && it > 0){
            it--;
        }
        if(it == 0){
            cout << 1;
        }
        else{
            cout << i + 2 - (n - it - 1) << " ";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for(int i = 0 ; i < n; ++i)
#define forall(i, x) for(auto (i) : (x))
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define fi first
#define se second
#define mp(x, y) make_pair((x), (y))
#define pb push_back
#define vc std::vector

typedef long long ll;

const ll INF = (ll)1e9;
int MOD;

istream& operator>>(istream & in, vc<int> &v){
    for(auto &i : v){
        in >> i;
    }
    return in;
}
ostream& operator<<(ostream & out, vc<int> &v){
    cout << v.size() << "\n";
    for(auto &i : v)
        out << i << " ";
    return out;
}

int main(){
    if(false) {
        freopen("io.txt", "r", stdin);
        freopen("io.txt", "a+", stdout);
    }
    int n;
    cin >> n;
    vc<bool> pos(n, false);
    printf("1 ");
    int it = n-1;
    forn(i, n){
        int c;
        scanf("%d", &c);
        c--;
        pos[c] = true;
        while(pos[it]!=false && it > 0){
            it--;
        }
        if(it == 0){
            printf("1 ");
        }
        else{
            printf("%d ", i + 2 - (n - it - 1));
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for(int i = 0 ; i < n; ++i)
#define forall(i, x) for(auto (i) : (x))
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define fi first
#define se second
#define mp(x, y) make_pair((x), (y))
#define pb push_back
#define vc std::vector

typedef long long ll;

const ll INF = (ll)1e9;
int MOD;

istream& operator>>(istream & in, vc<int> &v){
    for(auto &i : v){
        in >> i;
    }
    return in;
}
ostream& operator<<(ostream & out, vc<int> &v){
    cout << v.size() << "\n";
    for(auto &i : v)
        out << i << " ";
    return out;
}

int main(){
    if(false) {
        freopen("io.txt", "r", stdin);
        freopen("io.txt", "a+", stdout);
    }
    int n;
    cin >> n;
    vc<int> pos(n, 0);
    cout << "1 ";
    int it = n-1;
    forn(i, n){
        int c;
        cin >> c;
        c--;
        pos[c] = 1;
        while(pos[it]!=0 && it >= 0){
            it--;
        }
        cout << i + 2 - (n - it - 1) << " ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+5];

	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	set<int> s;
	set<int>::iterator it,it2;
	cout<<1<<" ";
	int count2,h=1;
	int flag=0,count=0;
	s.insert(n);
	s.insert(-1);
	int p=0;
	int lo=n;
	int count3;
	for(int i=0;i<n;i++){
		if(flag==0){
			if(a[i]==n){
				s.insert(a[i]);
				it=s.find(n);
				count3=1;
				lo=*it;
				while(1){

					--it;
					if(*it==-1)break;
					if(*it==a[i]-count3){
					count3++;
//					cout<<"p"<<p<<endl;
					lo=*it;
					p--;

					}
					else break;

				}
				count+=count3;
				//count+=count3;
	//			cout<<count<<endl;
				cout<<i+2-count<<" ";
				flag=1;
			}
			else{
			s.insert(a[i]);
			cout<<i+2<<" ";
			}
		}

		else{
			s.insert(a[i]);
			it=s.find(a[i]);
			it2=it;
			++it2;
			if(*it2==lo){
	//			cout<<"hi"<<" "<<a[i]<<" "<<lo<<endl;
				count2=1;
				lo=*it;
				while (1){
					--it;
				//	--it;
				//	cout<<*it<<endl;
					if(*it==-1)break;
				//cout<<"hi"<<a[i]-count2<<endl;
					if(*it==a[i]-count2)
					{
						count2++;
		//				cout<<count2<<endl;
						p--;
						lo=*it;
					}
					else break;
				}
			count+=count2;
	//			cout<<count2<<endl;
				cout<<i+2-count<<" ";
			}
			else{
				cout<<i+2-count<<" ";
			}
		}

	/*	if(a[i]==n){
			flag=1;
			//it=s.find(n)
			//for (it2=it
			cout<<i-count+1<<" ";
			h=h-count;
			count++;

		}
		else{
		s.insert(a[i]);
		set<int>::iterator k;
		k=s.find(a[i]);
		++k;

		if(*k==p and *k==a[i]+1 and flag==1){
			count++;
			p--;
		*if(*s.begin()==a[i]+1 and s.size()==n-a[i])cout<<i-count+1<<" ";}
		//else if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		else {
			if(flag==1)
			{		cout<<i+2-count<<" ";h+=1;}
			else cout<<i+2<<" ";
		}
		if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		}*/
//		cout<<"hi"<<*s.begin()<<endl;
	//	if(a[i]==n){s.insert(a[i]);
		 /*if(*s.begin()==a[i]+1 and flag==1){cout<<1<<" ";s.insert(a[i]);}
		else if(flag==0 and *s.begin()==a[i]+1){cout<<i+1+1<<" ";s.insert(a[i]);}
		 else {
			if(a[i]==n){flag=1;cout<<2<<" ";}
			else {cout<<i+1+1<<" ";}//s.insert(a[i]);}
		}*/
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+5];

	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	set<int> s;
	set<int>::iterator it,it2;
	cout<<1<<" ";
	int count2,h=1;
	int flag=0,count=0;
	s.insert(n);
	s.insert(-100000);
	int p=0;
	int lo=n;
	int count3;
	for(int i=0;i<n;i++){
		if(flag==0){
			if(a[i]==n){
				s.insert(a[i]);
				it=s.find(n);
				count3=1;
				lo=*it;
				while(1){

					--it;
					if(*it==-100000)break;
					if(count3>=a[i])break;
					if(*it==a[i]-count3){
					count3++;
//					cout<<"p"<<p<<endl;
					lo=*it;
					p--;

					}
					else break;

				}
				count+=count3;
				//count+=count3;
	//			cout<<count<<endl;
				cout<<i+2-count<<" ";
				flag=1;
			}
			else{
			s.insert(a[i]);
			cout<<i+2<<" ";
			}
		}

		else{
			s.insert(a[i]);
			it=s.find(a[i]);
			it2=it;
			++it2;
			if(*it2==lo){
	//			cout<<"hi"<<" "<<a[i]<<" "<<lo<<endl;
				count2=1;
				lo=*it;
				while (1){
					--it;
				//	--it;
				//	cout<<*it<<endl;
					if(*it==-100000)break;
					if(count2>=a[i])break;
				//cout<<"hi"<<a[i]-count2<<endl;
					if(*it==a[i]-count2)
					{
						count2++;
		//				cout<<count2<<endl;
						p--;
						lo=*it;
					}
					else break;
				}
			count+=count2;
	//			cout<<count2<<endl;
				cout<<i+2-count<<" ";
			}
			else{
				cout<<i+2-count<<" ";
			}
		}

	/*	if(a[i]==n){
			flag=1;
			//it=s.find(n)
			//for (it2=it
			cout<<i-count+1<<" ";
			h=h-count;
			count++;

		}
		else{
		s.insert(a[i]);
		set<int>::iterator k;
		k=s.find(a[i]);
		++k;

		if(*k==p and *k==a[i]+1 and flag==1){
			count++;
			p--;
		*if(*s.begin()==a[i]+1 and s.size()==n-a[i])cout<<i-count+1<<" ";}
		//else if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		else {
			if(flag==1)
			{		cout<<i+2-count<<" ";h+=1;}
			else cout<<i+2<<" ";
		}
		if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		}*/
//		cout<<"hi"<<*s.begin()<<endl;
	//	if(a[i]==n){s.insert(a[i]);
		 /*if(*s.begin()==a[i]+1 and flag==1){cout<<1<<" ";s.insert(a[i]);}
		else if(flag==0 and *s.begin()==a[i]+1){cout<<i+1+1<<" ";s.insert(a[i]);}
		 else {
			if(a[i]==n){flag=1;cout<<2<<" ";}
			else {cout<<i+1+1<<" ";}//s.insert(a[i]);}
		}*/
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+5];

	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	set<int> s;
	set<int>::iterator it,it2;
	cout<<1<<" ";
	int count2,h=1;
	int flag=0,count=0;
	s.insert(n);
	s.insert(-100000);
	int p=0;
	int lo=n;
	int count3;
	for(int i=0;i<n;i++){
		if(flag==0){
			if(a[i]==n){
				s.insert(a[i]);
				it=s.find(n);
				count3=1;
				lo=*it;
				while(1){

					--it;
					if(*it==-100000)break;
					if(count3>=a[i])break;
					if(*it==a[i]-count3){
					count3++;
//					cout<<"p"<<p<<endl;
					lo=*it;
					p--;

					}
					else break;

				}
				count+=count3;
				//count+=count3;
	//			cout<<count<<endl;
				cout<<i+2-count<<" ";
				flag=1;
			}
			else{
			s.insert(a[i]);
			cout<<i+2<<" ";
			}
		}

		else{
			s.insert(a[i]);
			it=s.find(a[i]);
			it2=it;
			++it2;
			if(*it2==lo and *it + 1==*it2){
			//	cout<<"hi"<<" "<<a[i]<<" "<<*it2<<endl;
				count2=1;
				lo=*it;
				while (1){
					--it;
				//	--it;
				//	cout<<*it<<endl;
					if(*it==-100000)break;
					if(count2>=a[i])break;
				//cout<<"hi"<<a[i]-count2<<endl;
					if(*it==a[i]-count2)
					{
						count2++;
		//				cout<<count2<<endl;
						p--;
						lo=*it;
					}
					else break;
				}
			count+=count2;
	//			cout<<count2<<endl;
				cout<<i+2-count<<" ";
			}
			else{
		//		cout<<"hi"<<a[i]<<endl;
				cout<<i+2-count<<" ";
			}
		}

	/*	if(a[i]==n){
			flag=1;
			//it=s.find(n)
			//for (it2=it
			cout<<i-count+1<<" ";
			h=h-count;
			count++;

		}
		else{
		s.insert(a[i]);
		set<int>::iterator k;
		k=s.find(a[i]);
		++k;

		if(*k==p and *k==a[i]+1 and flag==1){
			count++;
			p--;
		*if(*s.begin()==a[i]+1 and s.size()==n-a[i])cout<<i-count+1<<" ";}
		//else if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		else {
			if(flag==1)
			{		cout<<i+2-count<<" ";h+=1;}
			else cout<<i+2<<" ";
		}
		if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		}*/
//		cout<<"hi"<<*s.begin()<<endl;
	//	if(a[i]==n){s.insert(a[i]);
		 /*if(*s.begin()==a[i]+1 and flag==1){cout<<1<<" ";s.insert(a[i]);}
		else if(flag==0 and *s.begin()==a[i]+1){cout<<i+1+1<<" ";s.insert(a[i]);}
		 else {
			if(a[i]==n){flag=1;cout<<2<<" ";}
			else {cout<<i+1+1<<" ";}//s.insert(a[i]);}
		}*/
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+5];

	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	set<int> s;
	set<int>::iterator it,it2;
	cout<<1<<" ";
	int count2,h=1;
	int flag=0,count=1;
	s.insert(n);
	s.insert(-1);
	int p=0;
	int lo=n;
	for(int i=0;i<n;i++){
		if(flag==0){
			if(a[i]==n){
				s.insert(a[i]);
				it=s.find(n);

				while(1){
					--it;
					if(*it==-1)break;
					if(*it==n-p-1){
					count++;
					lo=*it;
					p--;

					}
					else break;

				}
	//			cout<<count<<endl;
				cout<<i+2-count<<" ";
				flag=1;
			}
			else{
			s.insert(a[i]);
			cout<<i+2<<" ";
			}
		}

		else{
			s.insert(a[i]);
			it=s.find(a[i]);
			it2=it;
			++it2;
			if(*it2==lo){
	//			cout<<"hi"<<" "<<a[i]<<" "<<lo<<endl;
				count2=1;
				while (1){
					--it;
				//	--it;
				//	cout<<*it<<endl;
					if(*it==-1)break;
				//cout<<"hi"<<a[i]-count2<<endl;
					if(*it==a[i]-count2)
					{
						count2++;
		//				cout<<count2<<endl;
						p--;
						lo=*it;
					}
					else break;
				}
			count+=count2;
	//			cout<<count2<<endl;
				cout<<i+2-count<<" ";
			}
			else{
				cout<<i+2-count<<" ";
			}
		}

	/*	if(a[i]==n){
			flag=1;
			//it=s.find(n)
			//for (it2=it
			cout<<i-count+1<<" ";
			h=h-count;
			count++;

		}
		else{
		s.insert(a[i]);
		set<int>::iterator k;
		k=s.find(a[i]);
		++k;

		if(*k==p and *k==a[i]+1 and flag==1){
			count++;
			p--;
		*if(*s.begin()==a[i]+1 and s.size()==n-a[i])cout<<i-count+1<<" ";}
		//else if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		else {
			if(flag==1)
			{		cout<<i+2-count<<" ";h+=1;}
			else cout<<i+2<<" ";
		}
		if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		}*/
//		cout<<"hi"<<*s.begin()<<endl;
	//	if(a[i]==n){s.insert(a[i]);
		 /*if(*s.begin()==a[i]+1 and flag==1){cout<<1<<" ";s.insert(a[i]);}
		else if(flag==0 and *s.begin()==a[i]+1){cout<<i+1+1<<" ";s.insert(a[i]);}
		 else {
			if(a[i]==n){flag=1;cout<<2<<" ";}
			else {cout<<i+1+1<<" ";}//s.insert(a[i]);}
		}*/
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+5];

	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	set<int> s;
	set<int>::iterator it,it2;
	cout<<1<<" ";
	int count2,h=1;
	int flag=0,count=0;
	s.insert(n);
	s.insert(-1);
	int p=0;
	int lo=n;
	int count3;
	for(int i=0;i<n;i++){
		if(flag==0){
			if(a[i]==n){
				s.insert(a[i]);
				it=s.find(n);
				count3=1;
				while(1){

					--it;
					if(*it==-1)break;
					if(*it==a[i]-count3){
					count3++;
//					cout<<"p"<<p<<endl;
					lo=*it;
					p--;

					}
					else break;

				}
				count+=count3;
				//count+=count3;
	//			cout<<count<<endl;
				cout<<i+2-count<<" ";
				flag=1;
			}
			else{
			s.insert(a[i]);
			cout<<i+2<<" ";
			}
		}

		else{
			s.insert(a[i]);
			it=s.find(a[i]);
			it2=it;
			++it2;
			if(*it2==lo){
	//			cout<<"hi"<<" "<<a[i]<<" "<<lo<<endl;
				count2=1;
				while (1){
					--it;
				//	--it;
				//	cout<<*it<<endl;
					if(*it==-1)break;
				//cout<<"hi"<<a[i]-count2<<endl;
					if(*it==a[i]-count2)
					{
						count2++;
		//				cout<<count2<<endl;
						p--;
						lo=*it;
					}
					else break;
				}
			count+=count2;
	//			cout<<count2<<endl;
				cout<<i+2-count<<" ";
			}
			else{
				cout<<i+2-count<<" ";
			}
		}

	/*	if(a[i]==n){
			flag=1;
			//it=s.find(n)
			//for (it2=it
			cout<<i-count+1<<" ";
			h=h-count;
			count++;

		}
		else{
		s.insert(a[i]);
		set<int>::iterator k;
		k=s.find(a[i]);
		++k;

		if(*k==p and *k==a[i]+1 and flag==1){
			count++;
			p--;
		*if(*s.begin()==a[i]+1 and s.size()==n-a[i])cout<<i-count+1<<" ";}
		//else if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		else {
			if(flag==1)
			{		cout<<i+2-count<<" ";h+=1;}
			else cout<<i+2<<" ";
		}
		if(*k==p and *k==a[i]+1 and flag==0){count++;p--;}
		}*/
//		cout<<"hi"<<*s.begin()<<endl;
	//	if(a[i]==n){s.insert(a[i]);
		 /*if(*s.begin()==a[i]+1 and flag==1){cout<<1<<" ";s.insert(a[i]);}
		else if(flag==0 and *s.begin()==a[i]+1){cout<<i+1+1<<" ";s.insert(a[i]);}
		 else {
			if(a[i]==n){flag=1;cout<<2<<" ";}
			else {cout<<i+1+1<<" ";}//s.insert(a[i]);}
		}*/
	}
	cout<<endl;
	return 0;
}