{"problem":{"name":"E. Blog Post Rating","description":{"content":"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 communi","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF806E"},"statements":[{"statement_type":"Markdown","content":"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.\n\nConsider 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.\n\nConsider 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.\n\nFor 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?\n\n## Input\n\nThe first line contains a single integer _n_ (1 ≤ _n_ ≤ 5·105) — the number of Codeforces users.\n\nThe second line contains _n_ integers _a_1, _a_2, ..., _a__n_ ( - 5·105 ≤ _a__i_ ≤ 5·105) — estimated blog post ratings for users in order from 1 to _n_.\n\n## Output\n\nFor 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.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"CF806E","tags":["data structures"],"sample_group":[["4\n2 0 2 2","1\n1\n2\n2"],["7\n2 -3 -2 5 0 -3 1","1\n0\n-1\n0\n1\n1\n2"]],"created_at":"2026-03-03 11:00:39"}}