VK Cup 2017 - Round 3
E
Blog Post Rating
Codeforces
3000
原题
← DF →
翻译中…

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*_{*i*}$. 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*_{*i*}$ 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?

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ ($1 ≤ *n* ≤ 5·10^{5}$) — the number of Codeforces users.

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($- 5·10^{5} ≤ *a*_{*i*} ≤ 5·10^{5}$) — estimated blog post ratings for users in order from 1 to $*n*$.

翻译中…

Output

翻译中…

For each $*k*$ from 1 to $*n*$, output a single integer equal to the maximum possible community rating of the blog post after users with indices from 1 to $*k*$, in some order, visit the blog post page, rate the blog post, and close the page.

翻译中…

样例

Input #1
4
2 0 2 2
Output #1
1
1
2
2
InputCopy OutputCopy
Input #2
7
2 -3 -2 5 0 -3 1
Output #2
1
0
-1
0
1
1
2
InputCopy OutputCopy
题目信息
题号
773E
时间限制
4 s
内存限制
256 MB
标签
数据结构
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。