It's well-known that blog posts are an important part of Codeforces platform. Every blog post has a global characteristic changing over time — its community rating. A newly created blog post's community rating is 0. Codeforces users may visit the blog post page and rate it, changing its community rating by +1 or -1.

Consider the following model of Codeforces users' behavior. The *i*-th user has his own estimated blog post rating denoted by an integer *a*<sub class="lower-index">*i*</sub>. When a user visits a blog post page, he compares his estimated blog post rating to its community rating. If his estimated rating is higher, he rates the blog post with +1 (thus, the blog post's community rating increases by 1). If his estimated rating is lower, he rates the blog post with -1 (decreasing its community rating by 1). If the estimated rating and the community rating are equal, user doesn't rate the blog post at all (in this case we'll say that user rates the blog post for 0). In any case, after this procedure user closes the blog post page and never opens it again.

Consider a newly created blog post with the initial community rating of 0. For each of *n* Codeforces users, numbered from 1 to *n*, his estimated blog post rating *a*<sub class="lower-index">*i*</sub> is known.

For each *k* from 1 to *n*, inclusive, the following question is asked. Let users with indices from 1 to *k*, in some order, visit the blog post page, rate the blog post and close the page. Each user opens the blog post only after the previous user closes it. What could be the maximum possible community rating of the blog post after these *k* visits?
The first line contains a single integer *n* (1 ≤ *n* ≤ 5·10<sup class="upper-index">5</sup>) — the number of Codeforces users.

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> ( - 5·10<sup class="upper-index">5</sup> ≤ *a*<sub class="lower-index">*i*</sub> ≤ 5·10<sup class="upper-index">5</sup>) — estimated blog post ratings for users in order from 1 to *n*.
none
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef pair<ll, ll> l4;
typedef long double ld;
typedef pair<ld,ld> ldd;
const ld pi = acosl(-1);
const int maxn = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
const ld eps = 1e-10;

int bit[2*maxn];
void add1(int x) {
    while (x < 2*maxn) {
        bit[x]++;
        x += x&-x;
    }
}
int sum(int x) {
    int ret = 0;
    while (x) {
        ret += bit[x];
        x -= x&-x;
    }
    return ret;
}

ii seg[8*maxn];
void init(int l, int r, int cur) {
    if (l == r) {
        seg[cur].fi = l;
        return;
    }
    int mid = (l+r)/2;
    init(l, mid, 2*cur);
    init(mid+1, r, 2*cur+1);
    seg[cur].fi = l;
}
void add(int l, int r, int L, int R, int cur) {
    if (l<=L && R<=r) {
        seg[cur].fi++, seg[cur].se++;
        return;
    }
    if (r<L || l>R) return;
    int mid = (L+R)/2;
    if (l <= mid) add(l, r, L, mid, 2*cur);
    if (mid < r) add(l, r, mid+1, R, 2*cur+1);
    seg[cur].fi = min(seg[2*cur].fi,seg[2*cur+1].fi)+seg[cur].se;
}
int query(int l, int r, int L, int R, int cur, int ad) {
    if (l<=L && R<=r) return seg[cur].fi+ad;
    if (r<L || l>R) return 1e9;
    int ans = 1e9;
    int mid = (L+R)/2;
    if (l <= mid) ans = min(ans,query(l, r, L, mid, 2*cur, ad+seg[cur].se));
    if (mid < r) ans = min(ans,query(l, r, mid+1, R, 2*cur+1, ad+seg[cur].se));
    return ans;
}
int n,t;
const int T = 5e5+1;

int main() {
    init(1, 2*T, 1);
    scanf("%d",&n);
    rep(i, 0, n) {
        scanf("%d",&t);
        add1(t+T);
        int l = -T, r = 0, mid,ans=0;
        while (l <= r) {
            mid = (l+r)/2;
            if (mid >= -sum(mid+T)) ans=mid, r=mid-1;
            else l = mid+1;
        }
        add(1, t+T-1, 1, 2*T, 1);
        printf("%d\n",query(ans+T, 2*T, 1, 2*T, 1, 0)-T);
    }
}
