Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import deque

def bfs():
    global ans
    d = [[float("inf")] * w for _ in range(h)]
    que = deque([])
    for i in range(h):
        for j in range(w):
           if A[i][j] == "#":
               que.append([i, j])
               d[i][j] = 0
            
    while que:
        p = que.popleft()
        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4): 
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and A[nx][ny] != "#" and d[nx][ny] == float("inf"):
                d[nx][ny] = d[p[0]][p[1]] + 1
                A[nx][ny] = "#"
                que.append([nx, ny])
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, d[i][j])


h, w = map(int, input().split())
A = [list(input()) for _ in range(h)]
ans = 0
bfs()

print(ans)

### FIXED CODE ###

from subprocess import call
call (('pypy3', '-c', """
from collections import deque

def main():
    h, w = map(int, input().split())
    A = [list(input()) for _ in range(h)]
    d = [[10**9] * w for _ in range(h)]
    que = deque([])
    
    for i in range(h):
        for j in range(w):
           if A[i][j] == "#":
               que.append([i, j])
               d[i][j] = 0
           else:
               d[i][j] = 10 ** 9
            
    while que:
        x, y = que.popleft()
        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4): 
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < h and 0 <= ny < w and d[nx][ny] == 10**9:
                d[nx][ny] = d[x][y] + 1
                que.append([nx, ny])
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, d[i][j])
    print(ans)
    
    return
    
main()

"""))
### BUGGY CODE ###

# エラトステネスの篩を使う！O(nloglogn)
N = int(input())
A = list(map(int,input().split()))

listA = [0] * (10**6+10)
ans = 0
for i in A:
    for j in range(i,10**6+10,i):
        if listA[j] != 0:
            listA[j] = 2
            continue
        else:
            listA[j] += 1

for i in A:
    if listA[i] == 1:
        ans += 1

print(ans)


### FIXED CODE ###

# エラトステネスの篩を使う！O(nloglogn)
N = int(input())
A = list(map(int,input().split()))

listA = [0] * (10**6+10)
ans = 0
for i in A:
    if listA[i] != 0:
            listA[i] = 2
            continue
    for j in range(i,10**6+10,i):
        listA[j] += 1

for i in A:
    if listA[i] == 1:
        ans += 1

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import collections
import copy
def dellist(items, indexes):
    for index in sorted(indexes, reverse=True):
        del items[index]

def solve(N: int, A: "List[int]"):
    counter = sorted(list(collections.Counter(A).values()),reverse=True)
    for i in range(1,N+1):
        if len(counter) < i:
            print(0)
            continue
        if counter[0]*i <= N:
            print(N//i)
            continue
        c = copy.deepcopy(counter)
        answer = 0
        while c:
            if len(c) < i:
                break
            remove_index = []
            for j in range(i):
                c[j]-=1
                if c[j] == 0:
                    remove_index.append(j)
            if remove_index:
                dellist(c,remove_index)
            answer += 1

        print(answer)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import collections

def solve(N: int, A: "List[int]"):
    counter = sorted(list(collections.Counter(A).values()),reverse=True)
    c_index = 0
    k=0
    for i in range(1,N+1):
        k+=1
        if len(counter)<i:
            print(0)
            continue
        while counter[c_index]*k > N and c_index<len(counter)-1:
            N-=counter[c_index]
            c_index+=1
            k-=1
        print(N//k)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

#ABC116D-VariousSushi.py

INPUT1 = [int(n) for n in input().split()]

N, K = INPUT1[0], INPUT1[1]
Parameters = []
Score, Test = 0, 0
flag1, flag2 = 0, 0


for i in range(N):
    INPUT2 = [int(m) for m in input().split()]
    Parameters.append((INPUT2[0], INPUT2[1]))

Parameters = sorted(Parameters, key=lambda x: x[1], reverse=True)

def SumScore(List, K):
    taste = 0
    kind = []
    for i in range(K):
        taste += List[i][1]
        kind.append(List[i][0])
    return taste + len(set(kind))**2

def SearchNew(List, K):
    kind = []
    newkind = -1
    for i in range(K):
        kind.append(List[i][0])
    kindset = set(kind)
    for i in range(len(List)-K):
        if List[K+i][0] not in kindset:
            newkind = K+i
            break
    return newkind

def SearchDouble(List, K):
    result = -1
    for i in range(K):
        leftkind = []
        for j in range(K):
            leftkind.append(List[j][0])
        testkind = List[K-1-i][0]
        leftkind.pop(K-1-i)
        if testkind in leftkind:
            result = K-1-i
            break
    return result

Score = SumScore(Parameters, K)

for t in Parameters:
    i = SearchNew(Parameters, K)
    j = SearchDouble(Parameters, K)
    Parameters[i], Parameters[j] = Parameters[j], Parameters[i]
    Test = SumScore(Parameters, K)
    if Score <= Test:
        Score = Test

print(Score)


### FIXED CODE ###

#ABC116D-VariousSushi.py

from sys import stdin
#from numpy import sum

input = stdin.readline

N, K = list(map(int, input().split()))
List1= []
kind = set()
point1, point2 = 0, 0

INPUT = [tuple(map(int, input().split())) for _ in range(N)]

INPUT.sort(key = lambda x: -x[1])

for ti, di in INPUT[:K]:
    point1 += di
    if ti in kind:
        List1.append(di)
    kind.add(ti)

point2 = len(kind)

Score = point1 + point2**2
Test = Score

List1POP = List1.pop

for ti, di in INPUT[K:]:
    if 0 >= len(List1):
        break
    if ti in kind:
        continue
    Test = Test - List1POP() + di + 2 * point2 + 1
    point2 += 1
    kind.add(ti)
    Score = max(Score, Test)

print(Score)
### BUGGY CODE ###

n = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))
A_list = sorted(A_list)
B_list = sorted(B_list)
C_list = sorted(C_list)
cnt = 0

def is_ok(arg):
    return B_list[arg] > A_list[i]

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

def is_ok2(arg):
    return C_list[arg] > B_list[j]

def bisect2(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok2(mid):
            ok = mid
        else:
            ng = mid
    return ok

for i in range(n): #Aを決定
    #Aより大きいBを探す
    B_key = bisect(-1, len(B_list)-1)
    if A_list[i] < B_list[B_key]:
        for j in range(B_key, n):
            #Bより大きいCを探す
            C_key = bisect2(-1, len(C_list)-1)
            if B_list[j] < C_list[C_key]:
                cnt += n-C_key
            else:
                break
    else:
        break

print(cnt)


### FIXED CODE ###

n = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))
A_list = sorted(A_list)
B_list = sorted(B_list)
C_list = sorted(C_list)
cnt = 0

def is_ok(arg): #　B　より小さい最大の　A
    return A_list[arg] < B_list[i]

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

def is_ok2(arg): #　B　より大きい最小の　A
    return C_list[arg] > B_list[i]

def bisect2(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok2(mid):
            ok = mid
        else:
            ng = mid
    return ok

for i in range(n): #Bを固定
    #Bより小さいAを探す
    A_key = bisect(len(A_list), 0)
    if A_list[A_key] < B_list[i]:
        #Bより大きいCを探す
        C_key = bisect2(-1, len(C_list)-1)
        if B_list[i] < C_list[C_key]:
            #print(A_key, i, C_key, A_list[A_key], B_list[i], C_list[C_key])
            cnt += (n-C_key)*(A_key+1)

print(cnt)
### BUGGY CODE ###

from math import ceil


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


def solve(goal, count, meta):
    if (goal <= 0):
        return count

    min_count = 999999999

    for m in meta:
        meta2 = list(meta)
        meta2.remove(m)
        c = solve(goal - m[3], count + m[0], meta2)
        if c < min_count:
            min_count = c

    for m in meta:
        if goal - m[0] * m[1] > 0:
            continue
        c = count + ceil(goal / m[1])
        if c < min_count:
            min_count = c
        break

    return min_count


def main():
    d, goal = tuple(input_ints())

    meta = list()
    for i in range(d):
        problems, bonus = tuple(input_ints())
        score = (i + 1) * 100
        meta.append((problems, score, bonus, score * problems + bonus))

    count = solve(goal, 0, meta)
    print(count)


main()


### FIXED CODE ###

from math import ceil


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


cache = dict()


def solve(goal, count, meta):
    if (goal <= 0):
        return count

    s = frozenset([m[1] for m in meta])
    if s in cache:
        return cache[s]

    min_count = 999999999

    for m in meta:
        meta2 = list(meta)
        meta2.remove(m)
        c = solve(goal - m[3], count + m[0], meta2)
        if c < min_count:
            min_count = c

    for m in reversed(meta):
        if goal - m[0] * m[1] > 0:
            continue
        c = count + ceil(goal / m[1])
        if c < min_count:
            min_count = c
        break

    cache[s] = min_count

    return min_count


def main():
    d, goal = tuple(input_ints())

    meta = list()
    for i in range(d):
        problems, bonus = tuple(input_ints())
        score = (i + 1) * 100
        meta.append((problems, score, bonus, score * problems + bonus))

    count = solve(goal, 0, meta)
    print(count)


main()
### BUGGY CODE ###

import heapq

X,Y,Z,K = map(int,input().split())
A, B, C = [], [], []
[heapq.heappush(A, -a) for a in map(int,input().split())]
[heapq.heappush(B, -b) for b in map(int,input().split())]
[heapq.heappush(C, -c) for c in map(int,input().split())]

max_A = [-heapq.heappop(A) for _ in range(min(K,X))]
max_B = [-heapq.heappop(B) for _ in range(min(K,Y))]
max_C = [-heapq.heappop(C) for _ in range(min(K,Z))]

ans_list = []
for max_a in max_A:
  for max_b in max_B:
    for max_c in max_C:
      heapq.heappush(ans_list, -sum([max_a,max_b,max_c]))
[print(-heapq.heappop(ans_list)) for _ in range(K)]

### FIXED CODE ###

import heapq

X,Y,Z,K = map(int,input().split())
A, B, C = [sorted(list(map(int,input().split())),reverse=True) for _ in range(3)]

Q = []
heapq.heappush(Q, [-(A[0]+B[0]+C[0]),0,0,0])
for _ in range(K):
  p, i, j, k = heapq.heappop(Q)
  print(-p)
  if i+1<X and [-(A[i+1]+B[j]+C[k]),i+1,j,k] not in Q: heapq.heappush(Q, [-(A[i+1]+B[j]+C[k]),i+1,j,k])
  if j+1<Y and [-(A[i]+B[j+1]+C[k]),i,j+1,k] not in Q: heapq.heappush(Q, [-(A[i]+B[j+1]+C[k]),i,j+1,k])
  if k+1<Z and [-(A[i]+B[j]+C[k+1]),i,j,k+1] not in Q: heapq.heappush(Q, [-(A[i]+B[j]+C[k+1]),i,j,k+1])
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))

leftMax = [0] * N
rightMax = [0] * N
leftMax[0] = P[0]
rightMax[-1] = P[-1]
for i in range(N - 1):
    leftMax[i + 1] = max(leftMax[i], P[i + 1])
    rightMax[N - 1 - (i + 1)] = max(rightMax[N - 1 - i], P[N - 1 - i])

ans = 0
for i in range(N):
    a, b, c, d = -1, -1, N, N
    p = P[i]
    if leftMax[i] != p:
        for L in range(i - 1, -1, -1):
            if P[L] > p:
                if b == -1:
                    b = L
                elif a == -1:
                    a = L
                else:
                    break
    if rightMax[i] != p:
        for R in range(i + 1, N):
            if P[R] > p:
                if c == N:
                    c = R
                elif d == N:
                    d = R
                else:
                    break
    left = (b - a) * (c - i)
    right = (d - c) * (i - b)
    ans += p * (left + right)

print(ans)


### FIXED CODE ###

class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        # for i in range(len(A)):
        #     self.__node[i + n] = A[i]
        # for i in range(n - 1, 0, -1):
        #     self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 0:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


def solve():
    N = int(input())
    P = map(int, input().split())
    plist = []
    for i, p in enumerate(P):
        plist.append((p, i))
    plist.sort(reverse=True)

    maxSeg = SegmentTree([-1] * N, max, -1)
    minSeg = SegmentTree([N] * N, min, N)

    cnt = 0
    for p, c in plist:
        l2 = maxSeg.get(0, c)
        l1 = -1 if l2 <= 0 else maxSeg.get(0, l2)

        r1 = minSeg.get(c + 1, N)
        r2 = N if r1 >= N - 1 else minSeg.get(r1 + 1, N)

        a = (l2 - l1) * (r1 - c)
        b = (r2 - r1) * (c - l2)
        cnt += p * (a + b)

        maxSeg.update(c, c)
        minSeg.update(c, c)

    print(cnt)


solve()
### BUGGY CODE ###

h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
d=[]
ma=0
for i in range(h):
  d.append([])
  for j in range(w):
    d[-1].append(abs(a[i][j]-b[i][j]))
    ma=max(abs(a[i][j]-b[i][j]),ma)
if ma==0:print(0);exit()
l=(h+w-1)*ma*2+1
dp=[[l*[0]for _ in range(w)]for _ in range(h)]
mid=l//2
for i in range(h):
  for j in range(w):
    c=d[i][j]
    if i==j==0:dp[0][0][mid-c]=dp[0][0][mid+c]=1
    else:
      for k in range(l):
        if i!=0:
          if k-c>=0:dp[i][j][k-c]+=dp[i-1][j][k]
          if k+c<l:dp[i][j][k+c]+=dp[i-1][j][k]
        if j!=0:
          if k-c>=0:dp[i][j][k-c]+=dp[i][j-1][k]
          if k+c<l:dp[i][j][k+c]+=dp[i][j-1][k]
for i in range(mid):
  if dp[h-1][w-1][mid-i]or dp[h-1][w-1][mid+i]:print(i);exit()

### FIXED CODE ###

h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
d=[[a[i][j]-b[i][j]for j in range(w)]for i in range(h)]
dp=[w*[0]for _ in range(h)]
dp[0][0]=1<<(80+d[0][0])|1<<(80-d[0][0])
for i in range(h):
  for j in range(w):
    if i!=0:
      dp[i][j]|=(dp[i-1][j]<<80+d[i][j])
      dp[i][j]|=(dp[i-1][j]<<80-d[i][j])
    if j!=0:
      dp[i][j]|=(dp[i][j-1]<<80+d[i][j])
      dp[i][j]|=(dp[i][j-1]<<80-d[i][j])
n=dp[-1][-1]|(1<<15000)
ans=1<<1000
for i in range(15000):
  if n&(1<<i):ans=min(ans,abs(i-(h+w-1)*80))
print(ans)
### BUGGY CODE ###

n = int(input())
*A, = map(int, input().split())

C = {a:0 for a in A}

for a in A:
    C[a] = C[a]+1

maxA = max(A)

D = {a:0 for a in A}

for a in A:
    t = 2
    while a*t <= maxA:
        if a*t in A:
            D[a*t] = D[a*t]+1
        t = t+1

counter = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        counter = counter+1
        
print(counter)

### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)
### BUGGY CODE ###

A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

m = []

for i in range(M):
    x, y, z = map(int, input().split())
    m.append([x, y, z])

m.sort(reverse = True,key = lambda x: x[2])

h = 100000
for i in a:
    for j in b:
        if i + j < h:
            h = i + j

ans = 100000
if a[m[0][0]-1] + b[m[0][1]-1] - m[0][2] > h:
    ans = h
else:
    ans = a[m[0][0]-1] + b[m[0][1]-1] - m[0][2]

print(ans)



### FIXED CODE ###

A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

m = []
am = min(a)
bm = min(b)

for i in range(M):
    x, y, z = map(int, input().split())

    m.append(a[x-1] + b[y-1] - z )



if am + bm > min(m):
    print(min(m))
else:
    print(am + bm)
### BUGGY CODE ###

N, x = map(int, input().split())
a = list(map(int, input().split()))
min_a = {}
for i in range(N):
    min_a[i] = a[i]
ans = 10 ** 18
for i in range(N):
    s = x * i
    for j in range(N):
        min_a[j] = min(min_a[j], a[(i + j) % N])
        s += min_a[j]
    ans = min(ans, s)
print(ans)

### FIXED CODE ###

N, x = map(int, input().split())
a = list(map(int, input().split()))
min_a = []
for i in a:
    min_a.append(i)
ans = 10 ** 18
for i in range(N):
    s = x * i
    for j in range(N):
        min_a[j] = min(min_a[j], a[(i + j) % N])
        s += min_a[j]
    ans = min(ans, s)
print(ans)
### BUGGY CODE ###

K,S=map(int,input().split())
ans=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k==S:
                ans+=1
print(ans)

### FIXED CODE ###

K,S=map(int,input().split())
ans=0
for i in range(K+1):
    for j in range(K+1):
        if S-i-j<=K and S-i-j>=0:
            ans+=1
print(ans)
### BUGGY CODE ###

from heapq import heappush, heappop

N, M, Start, Goal = map(int, input().split())
Start -= 1
Goal -= 1
adj_list = [[] for _ in range(N)]
for i in range(M):
  u, v, yen, sunuke = map(int, input().split())
  u -= 1
  v -= 1
  adj_list[u].append([u, v, yen, sunuke])
  adj_list[v].append([v, u, yen, sunuke])

def dijkstra(start, changed):
  res = {}
  q = [[0, start]]
  visited = {}

  while len(q)>0:
    money, city = heappop(q)
    if city in res:
      continue
    res[city] = money

    for from_city, to_city, yen, sunuke  in adj_list[city]:
      if changed:
        heappush(q, [money+sunuke, to_city])
      else:
        heappush(q, [money+yen, to_city])
        

  return res


min_yen_path = dijkstra(Start, False)
min_sunuke_path = dijkstra(Goal, True)

res = []
max_sunuke = 0
for i in reversed(range(N)):
  s = 10**15-min_yen_path[i]-min_sunuke_path[i]
  max_sunuke = max([s, max_sunuke]) 
  res.append(max_sunuke)
  
for i in reversed(res):
  print(i)


### FIXED CODE ###

from heapq import heappush, heappop

N, M, Start, Goal = map(int, input().split())
Start -= 1
Goal -= 1
adj_list = [[] for _ in range(N)]
for i in range(M):
  u, v, yen, sunuke = map(int, input().split())
  u -= 1
  v -= 1
  adj_list[u].append([u, v, yen, sunuke])
  adj_list[v].append([v, u, yen, sunuke])

def dijkstra(start, changed):
  res = [ -1 for _ in range(N) ]
  q = [[0, start]]
  visited = {}

  while len(q)>0:
    money, city = heappop(q)
    if res[city]>=0:
      continue
    res[city] = money

    for from_city, to_city, yen, sunuke  in adj_list[city]:
      if res[to_city]<0:
        cost = sunuke if changed else yen
        heappush(q, [money+[yen, sunuke][changed], to_city])
        

  return res


min_yen_path = dijkstra(Start, 0)
min_sunuke_path = dijkstra(Goal, 1)

res = []
max_sunuke = 0
for i in reversed(range(N)):
  s = 10**15-min_yen_path[i]-min_sunuke_path[i]
  max_sunuke = max([s, max_sunuke]) 
  res.append(max_sunuke)
  
for i in reversed(res):
  print(i)
### BUGGY CODE ###

import sys


def main():
    N = int(input())
    a = list(map(int, input().split()))
    num = 0
    blocks = 0

    while True:
        flag=0
        num += 1

        try:
            i = a.index(num)
            blocks += i
            del a[:i+1]
            flag=1

        except:
            if(num==1):
                print('-1')
                sys.exit()
        if(flag==0):
            blocks += len(a)
            print(blocks)
            sys.exit()

main()

### FIXED CODE ###

import sys

def main():
    N = int(input())
    a = list(map(int,input().split()))
    num = 1

    for i in a:
        if(i==num):
            num += 1

    if(num!=1):
        print(len(a) - num + 1)
    else:
        print('-1')

main()
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[]

for i in range(1,N+1):
  B.append(A.index(i)+1)

print(" ".join(map(str,B)))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [0]*N

for i in range(N):
  B[A[i]-1] = i+1
  
print(" ".join(map(str,B)))
### BUGGY CODE ###

numbers = input().split()
x = input().split()
y = input().split()
z = input().split()

k = int(numbers[3])

x.sort(reverse=True)
if len(x) > k:
    del x[k::]
y.sort(reverse=True)
if len(y) > k:
    del y[k::]
z.sort(reverse=True)
if len(z) > k:
    del z[k::]

answer = []

for i in x:
    for j in y:
        for k in z:
            price = int(i)+int(j)+int(k)
            answer.append(price)

answer.sort(reverse=True)
del answer[int(numbers[3])::]

for l in answer:
    print(l)


### FIXED CODE ###

numbers = input().split()
x = input().split()
y = input().split()
z = input().split()

k = int(numbers[3])

answer = []
for i in x:
    for j in y:
        price = int(i)+int(j)
        answer.append(price)
answer.sort(reverse=True)
del answer[k::]
f_ans = []
for m in answer:
    for n in z:
        price = m + int(n)
        f_ans.append(price)

f_ans.sort(reverse=True)
del f_ans[k::]

for l in f_ans:
    print(l)
### BUGGY CODE ###

import sys
N,Y = map(int,input().split(" "))

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000

if man_max > N:
    man_max = N
if go_max > N:
    go_max = N
if sen_max > N:
    sen_max = N

for k in range(man_max+1):
    for j in range(go_max+1):
        for i in range(sen_max+1):
            if (10000*k + 5000*j + 1000*i == Y):
                if i+j+k == N:
                    print(str(k)+" "+str(j) + " " + str(i))
                    sys.exit()

print("-1 -1 -1")

### FIXED CODE ###

import sys
N,Y = map(int,input().split(" "))

man_max = Y//10000

go_max = Y // 5000

sen_max = Y // 1000


for i in range(N,-1,-1):
    for j in range (N-i+1):
        if 10000*i +5000*j +1000*(N-(i+j)) == Y: 
            print(str(i)+" "+str(j) + " " + str(N-(i+j)))
            sys.exit()
print("-1 -1 -1")