Problem: There are n friends who want to give gifts for the New Year to each other. Each friend should give exactly one gift and receive exactly one gift. The friend cannot give the gift to himself.

For each friend the value f_i is known: it is either f_i = 0 if the i-th friend doesn't know whom he wants to give the gift to or 1 ≤ f_i ≤ n if the i-th friend wants to give the gift to the friend f_i.

You want to fill in the unknown values (f_i = 0) in such a way that each friend gives exactly one gift and receives exactly one gift and there is no friend who gives the gift to himself. It is guaranteed that the initial information isn't contradictory.

If there are several answers, you can print any.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of friends.

The second line of the input contains n integers f_1, f_2, ..., f_n (0 ≤ f_i ≤ n, f_i ≠ i, all f_i ≠ 0 are distinct), where f_i is the either f_i = 0 if the i-th friend doesn't know whom he wants to give the gift to or 1 ≤ f_i ≤ n if the i-th friend wants to give the gift to the friend f_i. It is also guaranteed that there is at least two values f_i = 0.

Output

Print n integers nf_1, nf_2, ..., nf_n, where nf_i should be equal to f_i if f_i ≠ 0 or the number of friend whom the i-th friend wants to give the gift to. All values nf_i should be distinct, nf_i cannot be equal to i. Each friend gives exactly one gift and receives exactly one gift and there is no friend who gives the gift to himself.

If there are several answers, you can print any.

Examples

Input


5
5 0 0 2 4


Output


5 3 1 2 4 


Input


7
7 0 0 1 4 0 6


Output


7 3 2 1 4 5 6 


Input


7
7 4 0 3 0 5 1


Output


7 4 2 3 6 5 1 


Input


5
2 1 0 0 0


Output


2 1 4 5 3 

Solution (in PYTHON3):

Solution:

# # n = int(input())
# # arr = list(map(int,input().split()))
# # dic = {}
# # for i in range(n):
# # 	dic[arr[i]] = i
# # arr.sort()
# # ans = [0]*n
# # teams = []
# # temp = []
# # temp.append(arr[-1])
# # ans = 0
# # for i in range(n-2,-1,-1):
# # 	if len(temp)>2:
# # 		minn = abs(temp[-1]-temp[0])
# # 		x = abs(arr[i]-temp[0])
# # 		if x<minn:
# # 			minn = x
# # 			temp.append(arr[i])
# # 		else:
# # 			ans+=minn
# # 			teams.append(temp)
# # 			temp = [arr[i]]
# # 	else:
# # 		temp.append(arr[i])
# # if len(temp)<3:
# # 	ans-=abs(teams[-1][-1]-teams[-1][0])
# # 	teams[-1]+=temp
# # 	ans+=abs(teams[-1][-1]-teams[-1][0])
# # else:
# # 	teams.append(temp)
# # 	ans+=abs(temp[-1]-temp[0])
# # print(ans)
# # print(teams)
# # for _ in range(int(input())):
# # 	n = int(input())
# # 	arr = list(map(int,input().split()))
# # 	a = []
# # 	for i in range(n):
# # 		a.append(i+1)
# # 	ans = [0]*n
# # 	vis = [False]*n
# # 	temp = [0]*n
# # 	x = 0
# # 	v = 0
# # 	while x<n:
# # 		for i in range(n):
# # 			temp[arr[i]-1] = a[i]
# # 		v+=1
# # 		a = temp[:]
# # 		# print(a)
# # 		for i in range(n):
# # 			if a[i]-1==i:
# # 				if  not vis[i]:
# # 					ans[i] = v
# # 					vis[i] = True
# # 					x+=1
# # 	print(*ans)


# # from itertools import combinations
# # def search(arr,x,minn):
# # 	n = len(arr)
# # 	v = n//2
# # 	mid = arr[v]
# # 	if x==mid:
# # 		return mid
# # 	if n==1:
# # 		return minn
# # 	else:
# # 		if x>mid:
# # 			# print(mid)
# # 			# print(arr[v:])
# # 			return search(arr[v+1:],x,minn)
# # 		else:
# # 			minn = min(minn,mid)
# # 			return search(arr[:v+1],x,minn)
# # po = [1]
# # for i in range(1,10):
# # 	po.append(po[-1]*3)
# # tot = set()
# # for i in range(1,len(po)+1):
# # 	x = (list(combinations(po,i)))
# # 	for i in x:
# # 		tot.add(sum(list(i)))
# # tot = list(tot)
# # tot.sort()
# # # print(tot[:10])
# # for _ in range(int(input())):
# # 	n = int(input())
# # 	# for i in tot:
# # 	# 	if i>=n:
# # 	x = search(po,n,10**4)
# # 	print(x)
# 			# break

# # 1,3,4,9,10,12
# for _ in range(int(input())):
# 	n = int(input())
# 	arr = list(map(int,input().split()))
# 	tot = [arr]
# 	tot_in = [[1,n]]
# 	boo = False
# 	ans = []
# 	maxx = max(arr)
# 	maxi = arr.index(maxx)
# 	mini = arr[maxi-1]
# 	t = 2
# 	for i in range(maxi-1,-1,-1):
# 		if maxx-min(arr[i:maxi+1])>=len(arr[i:maxi+1]):
# 			# print("1")
# 			boo = True
# 			ans = [i+1,maxi+1]
# 			break
# 	if not boo:
# 		t = 2
# 		for i in range(maxi+1,n):
# 			if maxx-min(arr[maxi:i+1])>=len(arr[maxi:i+1]):
# 				boo = True
# 				# print("2")
# 				ans = [maxi+1,i+1]
# 				break

# 	if not boo:
# 		print("NO")
# 	else:
# 		print("YES")
# 		print(ans[0],ans[1])

# for _ in range(int(input())):
n = int(input())
arr = list(map(int,input().split()))
d1 = set()
for i in range(1,n+1):
	d1.add(i)
d2 = set()
for i in range(n):
	if arr[i]==0:
		d2.add(i+1)
	else:
		d1.remove(arr[i])

f1 = list(d1)
f2 = list(d2)
f = len(f2)
for i in range(f):
	if f2[i]==f1[i]:
		if i<f-1:
			f1[i],f1[i+1] = f1[i+1],f1[i]
		else:
			f1[i],f1[0] = f1[0],f1[i]
for i in range(f):
	arr[f2[i]-1] = f1[i]
print(*arr)