Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged in a row in such a way that firstly come coins out of circulation, and then come coins still in circulation. 

For arranging coins Dima uses the following algorithm. One step of his algorithm looks like the following:

  He looks through all the coins from left to right;  If he sees that the i-th coin is still in circulation, and (i + 1)-th coin is already out of circulation, he exchanges these two coins and continues watching coins from (i + 1)-th.  

Dima repeats the procedure above until it happens that no two coins were exchanged during this procedure. Dima calls hardness of ordering the number of steps required for him according to the algorithm above to sort the sequence, e.g. the number of times he looks through the coins from the very beginning. For example, for the ordered sequence hardness of ordering equals one.

Today Sasha invited Dima and proposed him a game. First he puts n coins in a row, all of them are out of circulation. Then Sasha chooses one of the coins out of circulation and replaces it with a coin in circulation for n times. During this process Sasha constantly asks Dima what is the hardness of ordering of the sequence. 

The task is more complicated because Dima should not touch the coins and he should determine hardness of ordering in his mind. Help Dima with this task. 


-----Input-----

The first line contains single integer n (1 ≤ n ≤ 300 000) — number of coins that Sasha puts behind Dima.

Second line contains n distinct integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — positions that Sasha puts coins in circulation to. At first Sasha replaces coin located at position p_1, then coin located at position p_2 and so on. Coins are numbered from left to right.


-----Output-----

Print n + 1 numbers a_0, a_1, ..., a_{n}, where a_0 is a hardness of ordering at the beginning, a_1 is a hardness of ordering after the first replacement and so on. 


-----Examples-----
Input
4
1 3 4 2

Output
1 2 3 2 1

Input
8
6 8 3 4 7 2 1 5

Output
1 2 2 3 4 3 4 5 1



-----Note-----

Let's denote as O coin out of circulation, and as X — coin is circulation.

At the first sample, initially in row there are coins that are not in circulation, so Dima will look through them from left to right and won't make any exchanges.

After replacement of the first coin with a coin in circulation, Dima will exchange this coin with next three times and after that he will finally look through the coins and finish the process.

XOOO  →  OOOX

After replacement of the third coin, Dima's actions look this way:

XOXO  →  OXOX  →  OOXX

After replacement of the fourth coin, Dima's actions look this way:

XOXX  →  OXXX

Finally, after replacement of the second coin, row becomes consisting of coins that are in circulation and Dima will look through coins from left to right without any exchanges.

Difficulty: MEDIUM

Solutions:
def f(n, a):
	a = list(map(lambda s: s - 1, a))
	ar = [0] * (n + 1)
	l = 0
	ans = [1]
	hi = n - 1
	cnt = 0
	for i in a:
		if i == hi:
			ar[i] = 1
			hi -= 1
			while ar[hi] == 1:
				hi -= 1
				cnt -= 1
		else:
			ar[i] = 1
			cnt += 1
		ans.append(cnt + 1)
	return ans
a = int(input())
ls = list(map(int, input().strip().split()))
print(*f(a, ls))


import sys
input = sys.stdin.readline
n = int(input())
p = list(map(int, input().split()))
flag = [1] * n
r = n - 1
cnt = 0
print(1, end=' ')
for i in range(n - 1):
	flag[p[i] - 1] = 0
	while flag[r] == 0:
		r -= 1
		cnt += 1
	print(i + 2 - cnt, end=' ')
print(1)


n = int(input())
x = [0] * n
a = 0
p = list(map(int, input().split()))
z = n - 1
ans = ['1']
for i in range(n):
	x[p[i] - 1] = 1
	a += 1
	while z > -1 and x[z] == 1:
		z -= 1
		a -= 1
	ans.append(str(a + 1))
print(' '.join(ans))


n = int(input())
input_ = list(map(int, input().split()))
pos = n
a = [0 for i in range(n + 1)]
res = 1
ans = [1]
for x in input_:
	a[x] = 1
	res += 1
	while a[pos] == 1:
		pos -= 1
		res -= 1
	ans.append(res)
print(' '.join(map(str, ans)))


n = int(input())
positions = [int(x) for x in input().split(' ')]
output = '1 '
pointer_to_right_wall = n - 1
coins = [False for i in range(len(positions))]
filled = 1
for i in range(len(positions)):
	coins[positions[i] - 1] = True
	if positions[i] - 1 == pointer_to_right_wall:
		count = 0
		while coins[pointer_to_right_wall] == True:
			if pointer_to_right_wall == 0 and coins[0] == True:
				count += 1
				break
			pointer_to_right_wall -= 1
			count += 1
		filled = filled - count + 1
	else:
		filled += 1
	output += str(filled) + ' '
print(output[:-1])


from sys import stdin, stdout
n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))
used = [0 for i in range(n)]
(right, cnt) = (n, 0)
ans = 1
stdout.write(str(ans) + ' ')
for v in values:
	used[v - 1] = 1
	ans += 1
	while right and used[right - 1]:
		ans -= 1
		right -= 1
	stdout.write(str(ans) + ' ')


n = int(input())
P = list(map(int, input().split()))
P[:] = [x - 1 for x in P]
lst = [0] * n
i = 0
S = n - 1
ans = [1] * (n + 1)
while i < n:
	lst[P[i]] = 1
	if P[i] == S:
		k = 0
		while k == 0:
			S += -1
			if lst[S] == 0 or S == -1:
				k = 1
	i += 1
	ans[i] = i - n + S + 2
print(' '.join(map(str, ans)))


n = int(input())
p = [int(x) for x in input().split()]
mx = n
a = [0] * (n + 1)
ans = [1]
for i in range(0, n):
	t = p[i]
	a[t] = 1
	while a[mx] == 1 and mx >= 1:
		mx -= 1
	ans.append(i + 1 - (n - mx) + 1)
print(' '.join(map(str, ans)))


n = int(input())
arr = list(map(int, input().split()))
ar2 = [False] * (n + 2)
ar2[-1] = True
res = [1]
acc = 1
ptr = n
for e in arr:
	ar2[e] = True
	acc += 1
	while ar2[ptr]:
		ptr -= 1
	res.append(acc - (n - ptr))
print(*res)


n = int(input())
l = list(map(int, input().split()))
print(1, end=' ')
ptr = n - 1
v = [0] * n
for i in range(n):
	v[l[i] - 1] = 1
	while ptr >= 0 and v[ptr] == 1:
		ptr -= 1
	print(i + 1 - (n - 1 - ptr) + 1, end=' ')


n = int(input())
a = list(map(int, input().split()))
p = [0] * (n + 1)
ans = [1] * (n + 1)
ind = n
for i in range(n):
	p[a[i] - 1] = 1
	while ind > 0 and p[ind - 1] == 1:
		ind -= 1
	ans[i + 1] = 1 + (i + 1) - (n - ind)
print(' '.join(map(str, ans)))


import sys
input = sys.stdin.readline
from collections import defaultdict
n = int(input())
ans = [0 for _ in range(n + 1)]
ans[0] = 1
ans[-1] = 1
sample = [0 for _ in range(n)]
last = n - 1
q = list(map(int, input().split()))
for i in range(n - 1):
	x = q[i]
	sample[x - 1] = 1
	if x - 1 == last:
		while sample[x - 1] != 0:
			x -= 1
		last = x - 1
	target = n - i - 2
	ans[i + 1] = last - target + 1
print(*ans)


n = int(input())
l = list(map(int, input().split()))
p = n
iss = set()
ans = [1]
out = 1
for i in range(n):
	if l[i] == p:
		p -= 1
		while p in iss:
			p -= 1
			out -= 1
		ans.append(out)
	else:
		iss.add(l[i])
		out += 1
		ans.append(out)
print(*ans)


n = int(input())
p = list(map(int, input().split()))
lp = n + 1
ans = [1]
vis = [0 for i in range(n)]
ans = [1]
top = n
hardness = 1
for i in range(len(p)):
	vis[p[i] - 1] = 1
	hardness += 1
	while vis[top - 1] == 1 and top > 0:
		top -= 1
		hardness -= 1
	ans.append(hardness)
print(' '.join([str(i) for i in ans]))