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

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = list(set(a))
ans = 0
for i in b:
    c = a.count(i)
    if i > n or c < i:
        ans += c
    if c > i:
        ans += c - i
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1
ans = 0
for i in d:
    if d[i] < i:
        ans += d[i]
    if d[i] > i:
        ans += d[i] - i
print(ans)
### BUGGY CODE ###

def resolve():
    from scipy.sparse.csgraph import dijkstra
    from scipy.sparse import csr_matrix
    import numpy as np
    n, m = map(int, input().split())
    edge = np.array([input().split() for _ in range(m)], dtype=np.int64).T
    a = csr_matrix(([1] * m, (edge - 1)), shape=(n, n))
    p = dijkstra(a, return_predecessors=True, min_only=True, indices=0, directed=False, unweighted=True)
    if min(p[1][1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1][1:]:
            print(i + 1)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

def resolve():
    def Dijkstra(s, n, edge, inf=float("inf")):
        import heapq
        d = [inf] * n
        used = [False] * n
        d[s] = 0
        used[s] = True
        queue = []
        path = [-9999] * n
        for e in edge[s]:
            heapq.heappush(queue, e + [s])
        while len(queue):
            dist, point, before = heapq.heappop(queue)
            if used[point]:
                continue
            d[point] = dist
            used[point] = True
            path[point] = before
            for nextdist, nextp in edge[point]:
                if not used[nextp]:
                    heapq.heappush(queue, [dist + nextdist, nextp, point])
        return d, path
    n, m = map(int, input().split())
    inf = 10 ** 10
    edge = [[] for _ in range(n)]
    for _ in range(m):
        x, y = [int(x) - 1 for x in input().split()]
        edge[x].append([1, y])
        edge[y].append([1, x])
    l, p = Dijkstra(0, n, edge, inf)
    if min(p[1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1:]:
            print(i + 1)


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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n):
        b = sorted(a[:i] + a[i+1:])
        print(b[n // 2 - 1])

        
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sorted(a)
    
    for i in range(n):
        if a[i] <=  b[n // 2 - 1]:
            print(b[n // 2])
        elif a[i] >  b[n // 2 - 1]:
            print(b[n // 2 - 1])
        
        
if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
S = input()

resset = set()

def set_range(start,end):
    return set(i for i in range(start, end))

range1 = set(i for i in range(0,N))

for i in range1:
    range2 = set(i for i in range(i+1,N))
    for j in range2:
        range3 = set(i for i in range(j+1,N))
        for k in range3:
            temp = S[i] + S[j] + S[k]
            resset.add(temp)

print(len(resset))


### FIXED CODE ###

N = int(input())
S = input()

res = 0

for i in range(10):
    p1 = S.find(str(i))
    if p1 == -1:
        continue
    elif p1 > N-3:
        continue
    for j in range(10):
        p2 = S[p1+1:N].find(str(j))
        if p2 == -1:
            continue
        elif p2 > N-p1-3:
            continue
        for k in range(10):
            p3 = S[p1+p2+2:N].find(str(k))
            if p3 == -1:
                continue
            res += 1


print(res)
### BUGGY CODE ###

import sys
#from collections import defaultdict
sys.setrecursionlimit(10**6)

def input():
	return sys.stdin.readline()[:-1]
n, l = map(int, input().split())
ss = [input() for _ in range(n)]

def addTree(tree, sentence):
	if not sentence[0:]:
		return None   

	if sentence[0] not in tree:
		tree[sentence[0]] = {}

	tree[sentence[0]] = addTree(tree[sentence[0]], sentence[1:])

	return tree

def createTree(sentences):    
	tree = {}
	for sentence in sentences:
		tree = addTree(tree, sentence)

	return tree

tree = createTree(ss)
#print(tree)

grundy = 0
def dfs(cur, level):
	global grundy
	if cur is None:
		return
	elif len(cur) == 1:
		grundy ^= (l-level) & (-l+level)
	for k in cur.keys():
		dfs(cur[k], level+1)
	return
	
dfs(tree, 0)

if grundy == 0:
	print("Bob")
else:
	print("Alice")

### FIXED CODE ###

import sys
#from collections import defaultdict
sys.setrecursionlimit(10**6)

def input():
	return sys.stdin.readline()[:-1]
n, l = map(int, input().split())
ss = [list(input())[::-1] for _ in range(n)]

def addTree(tree, sentence):
	if not sentence:
		return None   

	if sentence[-1] not in tree:
		tree[sentence[-1]] = {}

	p = sentence.pop()
	tree[p] = addTree(tree[p], sentence)

	return tree

def createTree(sentences):    
	tree = {}
	for sentence in sentences:
		tree = addTree(tree, sentence)

	return tree

tree = createTree(ss)
#print(tree)

grundy = 0
def dfs(cur, level):
	global grundy
	if cur is None:
		return
	elif len(cur) == 1:
		grundy ^= (l-level) & (-l+level)
	for k in cur.keys():
		dfs(cur[k], level+1)
	return
	
dfs(tree, 0)

if grundy == 0:
	print("Bob")
else:
	print("Alice")
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import numpy as np
c = [[int(x) for x in input().split()] for _ in range(3)]

c = np.array(c)

for i in range(101):
    for j in range(101):
        for k in range(101):
            if (c[0] - i == c[1] - j).all() and (c[1] - j == c[2] - k).all():
                print("Yes")
                sys.exit()
print("No")



### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
c = []
for _ in range(3):
    c.append([int(x) for x in input().split()])
c = np.array(c)
c_t = c.T
a = c[1] - c[0]
b = c[2] - c[1]
d = c[2] - c[0]
e = c_t[1] - c_t[0]
f = c_t[2] - c_t[1]
g = c_t[2] - c_t[0]
x = []
x.append(a)
x.append(b)
x.append(d)
x.append(e)
x.append(f)
x.append(g)
x = np.array(x)
for i in x:
    if i[0] != i[1] or i[1] != i[2] or i[2] != i[0]:
        print("No")
        sys.exit()
print("Yes")
### BUGGY CODE ###

import math

n = int(input())
x = list(map(int, input().split()))
ans = 0
p = math.factorial(n-1)
for i in range(n-1):
  k = p//(i+1) % 1000000007
  ans += k * (x[n-1]-x[i])
  ans %= 1000000007
print(ans)


### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
ans = 0
mod = 1000000007
p = 1
for i in range(1, n):
  p *= i
  p %= mod
for i in range(n-1):
  ans += (x[n-1]-x[i])*pow(i+1, mod-2, mod)
ans *= p
ans %= 1000000007
print(ans)
### BUGGY CODE ###

#AGC040A
import sys
s = sys.stdin.readline().rstrip()
n = len(s)
L = [0 for i in range(n+1)]
f = False
while (f==False):
    f = True
    for i in range(n):
        if s[i] =='<' and not L[i+1] >L[i]:
            L[i+1] = L[i]+1
            f = False
        elif s[i] == '>' and not L[i] > L[i+1]:
            L[i] = L[i+1] +1
            f = False
#print(*L)
print(sum(L))


### FIXED CODE ###

#AGC040
import sys
s = sys.stdin.readline().rstrip()
n = len(s)
L = [0 for _ in range(n+1)]

for i in range(n):
    if s[i] == '<':
        L[i+1] = L[i] +1

#print(L)

for i in range(n-1,-1,-1):
    if s[i] == '>':
        L[i] = max(L[i], L[i+1]+1)

#print(L)

print(sum(L))
### BUGGY CODE ###



n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(1,n+1):
  print(a.index(i)+1 , end=' ')


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[x for x in range(n)]
for i in range(n):
  ans[(a[i] - 1)] = i + 1
for aaa in ans:
  print(aaa)
### BUGGY CODE ###

K=int(input()) 
num=0
a=1
cnt=0
while True:
  num+=1
  s=str(num)
  l=len(s)
  array=list(map(int,s))
  if l==1:
    a=num
    cnt+=1
  elif all(abs(array[j+1]-array[j])<=1 for j in range(l-1)):
    a=num
    cnt+=1
  if cnt==K:
    break
print(a)

### FIXED CODE ###

K=int(input())
a=set([1,2,3,4,5,6,7,8,9])
prev=set([1,2,3,4,5,6,7,8,9])

while len(a)<K:
  temp=set()
  for now in prev:
    c=now%10
    if c==0:
      temp.add(now*10)
      temp.add(now*10+1)
    elif c==9:
      temp.add(now*10+9)
      temp.add(now*10+8)
    else:
      temp.add(now*10+c-1)
      temp.add(now*10+c)
      temp.add(now*10+c+1)
  prev=temp
  a=a|temp
print(sorted(list(a))[K-1])
### BUGGY CODE ###

H,W = map(int,input().split())
A = [list(input()) for i in range(H)]
S = [[0]*W for i in range(H)]
for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            S[h][w] = H*W
for h in range(H):
    a = 0
    for w in range(W):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for w in range(W)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
for w in range(W):
    a = 0
    for h in range(H):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for h in range(H)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
ans = H*W
for h in range(H):
    for w in range(W):
        ans = min(ans,S[h][w])
print(H*W-ans)

### FIXED CODE ###

H,W = map(int,input().split())
A = [list(input()) for i in range(H)]
S = [[0]*W for i in range(H)]
for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            S[h][w] = H*W
for h in range(H):
    a = 0
    for w in range(W):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for w in range(W)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
for w in range(W):
    a = 0
    for h in range(H):
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
    for h in range(H)[::-1]:
        S[h][w] = max(a,S[h][w])
        a = max(a,S[h][w])-1
ans = H*W
for h in range(H):
    for w in range(W):
        ans = min(ans,S[h][w])
print(H*W-ans)
### BUGGY CODE ###

from collections import Counter


class Memoize:
    def __init__(self, fn):
        self.fn = fn
        self.memo = {}

    def __call__(self, c, x):
        if x not in self.memo:
            self.memo[x] = self.fn(c, x)
        return self.memo[x]


@Memoize
def cal(c, x):
    s = 0
    for i in c:
        if i == x:
            s += combinations_count(c[i]-1)
        else:
            s += combinations_count(c[i])
    return s


def combinations_count(n):
    return n*(n-1)//2


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(a)
    for i in range(n):
        print(cal(c, a[i]))


### FIXED CODE ###

from collections import Counter


def combinations_count(n):
    return n*(n-1)//2


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(a)
    t = 0
    for i in c:
        t += combinations_count(c[i])

    for i in range(n):
        print(t-c[a[i]]+1)
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
for i in range(1,n):
	dp[i]=min([dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)])
print(dp[-1])

### FIXED CODE ###

def flog2():
	import sys
	def input():return sys.stdin.readline()
	n,k=[int(i) for i in input().split()]
	h=[int(i) for i in input().split()]
	dp=[float('inf')]*n
	dp[0]=0
	for i in range(1,n):
		dp[i]=min([dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)])
	print(dp[-1])
	
if __name__ == "__main__":
	flog2()
### BUGGY CODE ###

if __name__ == "__main__":
    n, m = map(int, input().split())

    nexts = [[]] * n
    
    for i in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        if len(nexts[ai]) == 0:
            nexts[ai] = [bi]
        else:
            nexts[ai].append(bi)
        if len(nexts[bi]) == 0:
            nexts[bi] = [ai]
        else:
            nexts[bi].append(ai)

    scores = [m] * m
    scores[0] = 0

    red_set = [0]
    new_red_set = []
    blue_set = [x + 1 for x in range(n)]
    new_blue_set = blue_set

    arrows = [0] * n

    j = 0

    while len(blue_set) != 0:
        for r in red_set:
            for nxt in nexts[r]:
                if nxt in blue_set:
                    new_blue_set.remove(nxt)
                    new_red_set.append(nxt)
                    arrows[nxt] = r
        red_set = new_red_set
        new_red_set = []
        blue_set = new_blue_set
    
    print("Yes")
    for arrow in arrows[1:]:
        print(arrow + 1)
    

### FIXED CODE ###

from sys import stdin
from collections import deque
input = stdin.readline


def main():
    n, m = map(int, input().split())

    nexts = [[] for i in range(n)]
    
    for _ in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        nexts[ai].append(bi)
        nexts[bi].append(ai)

    blues = [-1] * n # 1 is in blues
    blues[0] = 0 # 0 is not in blues
    checked = [0] * n

    red_deque = deque([0])

    while len(red_deque) > 0:
        rd = red_deque[0]
        red_deque.popleft()
        if checked[rd] == 0:
            checked[rd] = 1
            for nxt in nexts[rd]:
                if blues[nxt] == -1:
                    blues[nxt] = rd
                    red_deque.append(nxt)

    print("Yes")
    for blue in blues[1:]:
        print(blue + 1)
    

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

n,m=map(int,input().split()) 
q=input() 
l=[list(map(int,input().split())) for _ in range(m)] 
for j in range(m): 
	cnt=0 
	for i in range(l[j][0],l[j][1]): 
		if (q[i-1]+q[i])=="AC": 
			cnt+=1 
	print(cnt) 

### FIXED CODE ###

n,m=map(int,input().split()) 
q=input() 
l=[list(map(int,input().split())) for _ in range(m)] 
ans=0 
lst_j=[0]*(n+1) 
for i in range(n-1): 
	cnt=0 
	if q[i]+q[i+1]=="AC": 
		cnt=1 
		lst_j[i+1]=cnt+lst_j[i] 
	else:lst_j[i+1]=lst_j[i] 
for i,j in l: 
	ans=lst_j[j-1]-lst_j[i-1] 
	print(ans)
### BUGGY CODE ###

from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
S = [0]+list(accumulate(A))
AS = [0]*N
count = 0
for i in range(N):
  AS[i] = A[i]+S[i]
for i in range(N):
  num = AS[i]
  for j in range(i+1,N):
    if num*2 >= A[j]:
      num += A[j]
      if j == N-1:
        ans = len(A)-count
        print(ans)
        exit()
    else:
      count += 1
      break

### FIXED CODE ###

from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
S = list(accumulate(A))
AS = []
flg = False
count = 0

for i in range(N-1):
  AS.append(S[i]*2 - A[i+1])
for j in range(N-2,-1,-1):
  if AS[j] < 0:
    count = j+1
    break
print(len(A)-count)
### BUGGY CODE ###

n=int(input())
list=[]
for i in range(n):
  s=input()
  if s not in list:
    list.append(s)
print(len(list))

### FIXED CODE ###

n=int(input())
s=[input() for i in range(n)]
s.sort()
d=0
for i in range(n-1):
    if s[i+1]==s[i]:
        d=d+1
print(n-d)
### BUGGY CODE ###

# from pprint import pprint
import math

# import numpy as np
# import collections

n = int(input())
# n = 10000000
# n = 100


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))


def g(x):
    y = n // x
    return int(y * (y + 1) * x / 2)


ans = 0
for i in range(1, n + 1):
    ans += g(i)


print(ans)

### FIXED CODE ###

# from pprint import pprint
import math
from numba import jit, njit

# import numpy as np
# import collections

n = int(input())
# n = 10000000
# n = 100


# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

def g(x):
    y = n // x
    return y * (y + 1) * x // 2


ans = 0
for i in range(1, n + 1):
    ans += g(i)

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

n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

num_counts = dict()
if len(set(num_lists)) <= k:
  ans = 0
else:
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
    numbers = list(num_counts.values())
    numbers.sort()
    ans = 0
  for i in range(len(set(num_lists)) - k):
    ans += numbers[i]

print(ans)


### FIXED CODE ###

from collections import Counter

n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

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

N, X, Y = map(int, input().split())

dp = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i+1, N):
        dp[i][j] = j-i
        dp[j][i] = j-i
dp[X-1][Y-1] = 1
dp[Y-1][X-1] = 1
for i in range(N):
    for j in range(N):
        if dp[i][j] > dp[i][X-1] + dp[X-1][j]:
            dp[i][j] = dp[i][X-1] + dp[X-1][j]
            dp[j][i] = dp[i][X-1] + dp[X-1][j]
        if dp[i][j] > dp[i][Y-1] + dp[Y-1][j]:
            dp[i][j] = dp[i][Y-1] + dp[Y-1][j]
            dp[j][i] = dp[i][Y-1] + dp[Y-1][j]

n_map = {}
for i in range(N):
    for j in range(i+1,N):
        if dp[i][j] not in n_map:
            n_map[dp[i][j]] = 1
        else:
            n_map[dp[i][j]] += 1
for i in range(1, N):
    if i not in n_map:
        print(0)
    else:
        print(n_map[i])

### FIXED CODE ###

N, X, Y = map(int, input().split())

dp = [[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i+1, N):
        dp[i][j] = j-i
        dp[j][i] = j-i
dp[X-1][Y-1] = 1
dp[Y-1][X-1] = 1
for i in range(N):
    for j in range(N):
        if dp[i][j] > dp[i][X-1] + dp[X-1][j]:
            dp[i][j] = dp[i][X-1] + dp[X-1][j]
            dp[j][i] = dp[i][X-1] + dp[X-1][j]
        if dp[i][j] > dp[i][Y-1] + dp[Y-1][j]:
            dp[i][j] = dp[i][Y-1] + dp[Y-1][j]
            dp[j][i] = dp[i][Y-1] + dp[Y-1][j]

n_map = {}
for i in range(N):
    for j in range(i+1,N):
        if dp[i][j] not in n_map:
            n_map[dp[i][j]] = 1
        else:
            n_map[dp[i][j]] += 1
for i in range(1, N):
    if i not in n_map:
        print(0)
    else:
        print(n_map[i])
### BUGGY CODE ###

N, X, Y= map(int, input().split(' '))
 
node = []
for k in range(1, N+1):
    for v in range(k, N+1):
       node.append(min([abs(k-v), abs(X-k)+abs(v-Y)+1, abs(Y-k)+abs(X-v)+1]))

for i in range(1, N):
    print(node.count(i))

### FIXED CODE ###

N, X, Y= map(int, input().split(' '))
 
array=[None]*N
for i in range(N):
    array[i]=0
    
for k in range(1, N+1):
    for v in range(k, N+1):
       array[min([abs(k-v), abs(X-k)+abs(v-Y)+1, abs(Y-k)+abs(X-v)+1])] += 1 

for i in range(1, N):
    print(array[i])
### BUGGY CODE ###

S=input()
N=len(S)
#「連続する区間」についての問題では、”累積和的なもの”をとるのが定石である。
#Sの連続する区間が、右からa文字分から、右からb文字分を取り除いたものであるとき
#その区間の整数が2019の倍数になるということは、s[a]とs[b]を2019で割ったあまりが等しい
#十分条件であることは分かったが、必要条件であるのか
#結論として必要条件でもある
#なぜなら2019と10は互いに素であるからである。

T=[]
T.append(0)
tmp=""
d=[0 for _ in range(2019)]
d[0]=1
r=0
t=1
for i in range(N):
    s=S[N-1-i]
    r+=int(s)*t
    r%=2019
    t*=10
    d[r]+=1

ans=0

print(sum(i*(i-1)//2 for i in d))

### FIXED CODE ###

S=input()
N=len(S)
#「連続する区間」についての問題では、”累積和的なもの”をとるのが定石である。
#Sの連続する区間が、右からa文字分から、右からb文字分を取り除いたものであるとき
#その区間の整数が2019の倍数になるということは、s[a]とs[b]を2019で割ったあまりが等しい
#十分条件であることは分かったが、必要条件であるのか
#結論として必要条件でもある
#なぜなら2019と10は互いに素であるからである。

T=[]
T.append(0)
tmp=""
d=[0 for _ in range(2019)]
d[0]=1
r=0
t=1
for i in range(N):
    s=S[N-1-i]
    r+=int(s)*t
    r%=2019
    t*=10
    t%=2019 
    d[r]+=1

ans=0

print(sum(i*(i-1)//2 for i in d))
### BUGGY CODE ###

n, m = map(int, input().split())


time_reward_tuple = []


for i in range(n):
    a, b = map(int, input().split())
    time_reward_tuple.append((a, b))

    
job_que = []


total = 0


for j in range(1, m+1):
    for l in [r for t, r in time_reward_tuple if t==j]:
        job_que.append(l)


    if job_que:
        job_que.sort()
        total += job_que.pop()
        
    
    
print(total)

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
t_r_list = []
for i in range(n):
    t_r_list.append(list(map(int, input().split())))

t_r_list.sort()
que = []
total = 0
l = 0
for j in range(1, m + 1):
    while True:
        if l == n:
            break
        if t_r_list[l][0] != j:
            break
        heapq.heappush(que, -t_r_list[l][1])
        l += 1

    if que:
        total -= heapq.heappop(que)


print(total)
### BUGGY CODE ###

sin = input()
n = int(sin)
sin = input()
arr = list(map(int, sin.split()))

tt = list()
for i in range(n):
    tt.append(i+1)

def bubble_sort(arr, tar):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i] > arr[i + 1]:
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                tar[i], tar[i + 1] = tar[i + 1], tar[i]
                change = True
    return arr, tar

a, b = bubble_sort(arr, tt)
print(' '.join(map(str, b)))

### FIXED CODE ###

sin = input()
n = int(sin)
sin = input()
arr = list(map(int, sin.split()))

db = list()
for i in range(n):
    db.append([arr[i], i+1])

ll = list()
for a in sorted(db, key=lambda x: x[0]):
    ll.append(a[1])

print(' '.join(map(str, ll)))
### BUGGY CODE ###

N,W=map(int,input().split())
w=[]
v=[]
for _ in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
V=sum(v)

dp=[[V+1 for _ in range(V+1)] for _ in range(N+1)]
dp[0][0]=0
ans=0

for i in range(N): #i番目の荷物を拾うかどうか
    for j in range(V+1): #価値jを超える重量の最小値
        dp[i+1][j]=min(dp[i][j],dp[i][max(0,j-v[i])]+w[i])
        if dp[i+1][j]<=W:
            ans=max(ans,j)
        
print(ans)

### FIXED CODE ###

N,W=map(int,input().split())
w=[]
v=[]
for _ in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
V=sum(v)

dp=[[10**9 for _ in range(V+1)] for _ in range(N+1)]
dp[0][0]=0
ans=0

for i in range(N): #i番目の荷物を拾うかどうか
    for j in range(V+1): #価値jを超える重量の最小値
        dp[i+1][j]=min(dp[i][j],dp[i][max(0,j-v[i])]+w[i])
        if dp[i+1][j]<=W:
            ans=max(ans,j)
        
print(ans)
### BUGGY CODE ###

H,W,D = tuple(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [tuple(map(int, input().split())) for _ in range(Q)]

Arev = [None] * (H*W+1)
for h in range(H):
  for w in range(W):
    Arev[A[h][w]] = (h,w)

for L,R in LR:
  mpsum = 0
  start = Arev[L]
  for x in range(L, R+1, D):
    next_ = Arev[x]
    mpsum += abs(start[0]-next_[0]) + abs(start[1]-next_[1])
    start = next_
  print(mpsum)


### FIXED CODE ###

import collections
import itertools
from pprint import pprint as pp

H,W,D = tuple(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [tuple(map(int, input().split())) for _ in range(Q)]

Arev = [None] * (H*W+1)
for h in range(H):
  for w in range(W):
    Arev[A[h][w]] = (h,w)

tbl = []
for i in range(D):
  ary = []
  mp = 0
  start = Arev[i+1]
  for x in range(i, H*W, D):
    next_ = Arev[x+1]
    mp += abs(start[0]-next_[0]) + abs(start[1]-next_[1])
    ary.append((x+1,mp))
    start = next_
  tbl.append(ary)
#pp(A)
#pp(tbl)
for L,R in LR:
  col1, row = divmod(L, D)
  col2 = R // D
  if row == 0:
    col1 -= 1
    col2 -= 1
  row -= 1
  #pp((row,col1,col2))
  print(tbl[row][col2][1] - tbl[row][col1][1])
### BUGGY CODE ###

N, P = map(int, input().split())
S = input()
ans = 0
if P in [2, 5]:
    for l, s in enumerate(S, 1):
        if int(s) % P == 0: ans += l
else:
    counter = {i: 0 for i in range(P)}
    counter[0] = 1
    for i in reversed(range(N)):
        num = int(S[i:]) % P
        ans += counter[num]
        counter[num] += 1
print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = input()
ans = 0
if P in [2, 5]:
    for l, s in enumerate(S, 1):
        if int(s) % P == 0: ans += l
else:
    counter = [0] * P
    counter[0] = 1
    prev = 0
    temp = 1
    for i, s in reversed(list(enumerate(S))):
        num = (int(s) * temp + prev) % P
        ans += counter[num]
        counter[num] += 1
        prev = num
        temp = (temp * 10) % P
print(ans)