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

R,G,B,N=map(int,input().split())
count=0
wa=0
for i in range(int(N/R)+1):
    for j in range(int((N-i*R)/G)+1):
        for k in range(int((N-i*R-j*G)/B)+1):
            wa=i*R+j*G+k*B
            if wa==N:
                count=count+1

print(count)

### FIXED CODE ###

R,G,B,N=map(int,input().split())
count=0
wa=0
for i in range(int(N/R)+1):
    for j in range(int((N-i*R)/G)+1):
        b=(N-i*R-j*G)/B
        if b>=0 and float.is_integer(b)==True:
            count=count+1

print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].append(b)
  #g[b].append(a)

ans = [0]*n  
for j in range(q):
  p, x = map(int, input().split())
  p -= 1
  ans[p] += x

def dfs(u, v):
  for v_ in g[v]:
    ans[v_] += ans[v]
    dfs(v, v_)

dfs(0,0)
print(' '.join(map(str, ans)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].append(b)
  #g[b].append(a)

ans = [0]*n  
for j in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
  
from collections import deque
s = deque()
s.append(0)

while s:
  v = s.pop()
  for v_ in g[v]:
    ans[v_] += ans[v]
    s.append(v_)

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

N=int(input())
A=list(map(int,input().split(' ')))

Asum=0
for i in range(N):
    Asum+=(A[i]*sum(A[0:i]))
    Asum=Asum%(10**9+7)
print(Asum)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split(' ')))

AjtoN=sum(A)
Asum=0
for i in range(N):
    AjtoN-=A[i]
    Asum+=A[i]*AjtoN
    Asum=Asum%(10**9+7)

print(Asum)
### BUGGY CODE ###

import itertools,sys
for a in sys.stdin:
  c=0
  n,s=map(int,a.split())
  for e in itertools.permutations(range(9),n):
    x=sum([i*j for i,j in zip(range(1,n+1),e)])
    if x==s: c+=1
  print c

### FIXED CODE ###

import sys
K=1024
N=331
R=range(K)
B=[1,2,4,8,16,32,64,128,256,512]
C=[0]*K
D=[[0 for i in range(N)]for j in R]

for i in R:
  s=format(i,'b')
  n=s.count('1')
  C[i]=n
  if n==1:D[i][B.index(i)]=1
  else:
    for j in range(len(s)):
      if s[-j-1]=='1':
        dp=n*j
        i2=i-B[j]
        for k in range(N-dp):
          D[i][k+dp]+=D[i2][k]
   
for a in sys.stdin:
  n,s=map(int,a.split())
  x=0
  if s<N:x=sum([D[i][s] for i in R if C[i]==n])
  print x
### BUGGY CODE ###

import math
import statistics
import copy

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

for i in range(N):
  a = copy.copy(li)
  a.pop(i)
  print(statistics.median(a))

### FIXED CODE ###

n = int(input())
s = list(map(int, input().split()))
sx = sorted(s)
a = sx[(n//2)-1]
b = sx[n//2]
for i in s:
  if i <= a:
    print(b)
  else:
    print(a)
### BUGGY CODE ###

n, k = map(int, input().split())
num = []
cnt = [0] * (10**5 + 1)
for _ in range(n):
    a, b = map(int, input().split())
    if a not in num:
        num.append(a)
    cnt[a] += b
num.sort()
ans = 0
for i in num:
    if cnt[i] >= k:
        ans = i
        break
    else:
        k -= cnt[i]
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
cnt = [0] * (10**5 + 1)
for _ in range(n):
    a, b = map(int, input().split())
    cnt[a] += b
for i in range(10**5 + 1):
    if k <= cnt[i]:
        ans = i
        break
    else:
        k -= cnt[i]
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
P = []
Y = []
for i in range(M):
  listA = list(map(int,input().split()))
  P.append(listA[0])
  Y.append(listA[1])
for i in range(M):
  num = 0
  for k in range(M):
    if P[i]==P[k] and Y[i]>=Y[k]:
      num+=1
  print(str(P[i]).rjust(6,'0')+str(num).rjust(6,'0'))

### FIXED CODE ###

N,M = map(int,input().split())
P = []
Y = []
arr = [[]for j in range(10**5+1)]
for i in range(M):
  listA = list(map(int,input().split()))
  P.append(listA[0])
  Y.append(listA[1])
  arr[listA[0]].append(listA[1])
for i in range(N+1):
  arr[i].sort()
for i in range(M):
  #二部探索
  left = 0
  right = len(arr[P[i]])-1
  while left <= right:
    mid = (left+right)//2
    if arr[P[i]][mid] == Y[i]:
      k = mid
      break
    elif arr[P[i]][mid] > Y[i]:
      right = mid-1
    else:
      left = mid+1
  print(str(P[i]).rjust(6,'0')+str(k+1).rjust(6,'0'))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = set(i for i in range(n))
ans = [0]*n
warizai_index = set()

for i in range(n):
    for wari in warizai_index:
        if a[i]%a[wari] == 0 and i != wari:
            ans[i] = 1
            #b.remove(i)
            break
    if ans[i] == 1:
        continue
    
    #for j in b:
    for j in range(n):
        if i == j:
            continue
        if a[i]%a[j] == 0:
            ans[i] = 1
            #if i in b:
            #    b.remove(i)
            warizai_index.add(j)
            #b.remove(j)
            break

print(ans.count(0))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
aMax = a[-1]
ans = 0
dp = [1] * (aMax+1)

for i in range(n-1):
    p = a[i]
    if dp[p] == 1:
        for j in range(aMax//p+1):
            dp[p*j] = 0
        if a[i] != a[i+1]:
            ans += 1
if dp[aMax] == 1:
    ans += 1
print(ans)
### BUGGY CODE ###


MOD = 10**9 + 7
S = input()

if len(S) % 3 == 1:
    S = '00' + S
elif len(S) % 3 == 2:
    S = '0' + S

L = (len(S) // 3)
dp = [[0 for i in range(14)] for j in range(L + 1)]
# print(rec(S, 0, 0) % MOD)
# print(memo)

dp[0][0] = 1

for k in range(L):
    for m in range(13):
        s = S[k*3:k*3+3]
        d1 = [str(i) for i in range(10)] if s[0] == '?' else [s[0]]
        d2 = [str(i) for i in range(10)] if s[1] == '?' else [s[1]]
        d3 = [str(i) for i in range(10)] if s[2] == '?' else [s[2]]

        for i1 in d1:
            for i2 in d2:
                for i3 in d3:
                    num = int(i1 + i2 + i3)
                    dp[k + 1][(13 + num - m) % 13] += dp[k][m]

        for i in range(13):
            dp[k+1][i] %= MOD

print(dp[L][5])

### FIXED CODE ###

MOD = 10**9 + 7

S = input()
L = len(S)
memo = [[0 for i in range(14)] for j in range(L + 1)]
dp = [[0 for i in range(14)] for j in range(L + 1)]

dp[0][0] = 1

for k in range(L):
    for m in range(13):
        if S[k] == '?':
            for i in range(10):
                dp[k + 1][(m * 10 + i) % 13] += dp[k][m]
        else:
            dp[k + 1][(m * 10 + int(S[k])) % 13] += dp[k][m]

        for i in range(13):
            dp[k+1][i] %= MOD

print(dp[L][5])
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
r, s, p = map(int, readline().split())
t = input()
ans = [0, 0, 0]
for i in range(k):
    if t[i] == 'r':
        ans[0] += 1
    elif t[i] == 's':
        ans[1] += 1
    else:
        ans[2] += 1
memo = []
for i in range(k, n):
    if t[i] == t[i - k] and (i - k) not in memo:
        memo.append(i)
    elif t[i] == 'r':
        ans[0] += 1
    elif t[i] == 's':
        ans[1] += 1
    elif t[i] == 'p':
        ans[2] += 1
print(ans[0] * p + ans[1] * r + ans[2] * s)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
r, s, p = map(int, readline().split())
t = input()
ans = [0, 0, 0]
check = t[:k]
for i in range(k, n):
    if t[i] == check[i - k]:
        check += 'a'
    else:
        check += t[i]
for i in range(k):
    if t[i] == 'r':
        ans[0] += 1
    elif t[i] == 's':
        ans[1] += 1
    else:
        ans[2] += 1
for i in range(k, n):
    if check[i] != check[i - k]:
        if check[i] == 'r':
            ans[0] += 1
        elif check[i] == 's':
            ans[1] += 1
        elif check[i] == 'p':
            ans[2] += 1
print(ans[0] * p + ans[1] * r + ans[2] * s)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
max_s = -10**9
for i in range(n-1):
    for j in range(i+1,n):
        R = s[j] - s[i]
        if max_s < R:
            max_s = R

print(max_s)



### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
max_s = -10**9
min_s = s[0]
for i in range(1, n):
    max_s = max(max_s, s[i] - min_s)
    min_s = min(min_s, s[i])

print(max_s)
### BUGGY CODE ###

def main():
    T = int(input())
    for _ in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        S = input()

        dp = [set() for i in range(N+1)]
        # 人１がビットを最後に立てた後に０にできるなら０にならない
        L = max(A).bit_length()
        dp[-1].add(0)
        for i in range(N-1, -1, -1):
            k = int(S[i])
            # print(A[i], dp[i+1], k)
            if k:
                if A[i] in dp[i+1]:
                    dp[i] = dp[i+1]

                else:
                    break
            else:
                dp[i] |= dp[i+1]
                for x in dp[i+1]:
                    dp[i].add(x ^ A[i])
        # print(dp)
        if len(dp[0]) > 0:
            print(0)
        else:
            print(1)
main()

### FIXED CODE ###

def main():
    T = int(input())
    for _ in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        S = input()
        L = max(A).bit_length()
        s = [0]*L
        ID = A.index(max(A))

        def check(x):
            for i in range(L-1, -1, -1):
                if (x >> i) % 2:
                    x ^= s[i]
            return(x == 0)

        def update(x):
            flag = False
            if x.bit_length() == 60:
                flag = True
            for i in range(L-1, -1, -1):
                if (x >> i) % 2:
                    x ^= s[i]
            id = x.bit_length() - 1
            if id >= 0:
                s[id] = x

        res = 0
        L2 = 0
        for i in range(N-1, -1, -1):
            k = int(S[i])
            if k:
                if check(A[i]):
                    continue
                else:
                    res = 1
                    break
            else:
                L2 = max(L2, A[i].bit_length())
                update(A[i])
        print(res)



main()
### BUGGY CODE ###

import math
import heapq

def dijkstra(v,s,path):
    inf = float('inf')

    # 距離をinfで初期化
    d = [inf for i in range(v)]
    d[s] = 0

    # sへの距離は0
    q = [[0,s]]
    heapq.heapify(q)

    # 距離が最小の頂点から更新していけば
    # p[1]から行ける
    while q:
        
        # 今回特別に追記
        if d[-1]==0:
            break
        
        p = heapq.heappop(q)

        # 頂点p[1]までの距離がheapないのp[1]までの距離より小さい場合、continue
        if d[p[1]]<p[0]:
            continue

        # 頂点p[1]から伸びる、全ての辺の距離を確認
        for i in range(len(path[p[1]])):
            # 頂点p[1]から行ける頂点の距離がp[1]までの距離とp[1]からの距離の和より小さい場合 -> 距離を更新し、heapに追加
            if d[path[p[1]][i][1]] > d[p[1]] + path[p[1]][i][0]:
                d[path[p[1]][i][1]] = d[p[1]]+path[p[1]][i][0]
                heapq.heappush(q,[d[path[p[1]][i][1]], path[p[1]][i][1]])
    return d

xs,ys,xt,yt = map(int,input().split())
n = int(input())
barrier = [list(map(int, input().split())) for i in range(n)]

barrier = [[xs,ys,0]] + barrier + [[xt,yt,0]]
n+=2

path = [[] for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        length = max(math.sqrt((barrier[i][0]-barrier[j][0])**2 + (barrier[i][1]-barrier[j][1])**2)-barrier[i][2]-barrier[j][2],0)
        path[i].append([length,j])
        path[j].append([length,i])

d = dijkstra(n,0,path)

print(d[-1])

### FIXED CODE ###

import math
import heapq

def dijkstra(s,path):
    inf = float('inf')
    n = len(path)

    # 距離をinfで初期化
    d = [inf for i in range(n)]
    d[s] = 0

    # sへの距離は0
    q = [(0,s)]
    heapq.heapify(q)

    # 距離が最小の頂点から更新していけば良い
    while q:
        c,p = heapq.heappop(q)

        # 頂点pまでの距離がheap内のpまでの距離より小さい場合、continue
        if d[p]<c:
            continue

        # 頂点pから伸びる、全ての辺の距離を確認
        for cost,to in path[p]:
            # 頂点pから行ける頂点の距離がpまでの距離とpからの距離の和より小さい場合 -> 距離を更新し、heapに追加
            if d[to] > d[p] + cost:
                d[to] = d[p]+cost
                heapq.heappush(q,(d[to], to))
    return d

xs,ys,xt,yt = map(int,input().split())
n = int(input())
barrier = [list(map(int, input().split())) for i in range(n)]

barrier = [[xs,ys,0]] + barrier + [[xt,yt,0]]
n+=2

path = [[] for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        length = max(math.sqrt((barrier[i][0]-barrier[j][0])**2 + (barrier[i][1]-barrier[j][1])**2)-barrier[i][2]-barrier[j][2],0)
        path[i].append([length,j])
        path[j].append([length,i])

d = dijkstra(0,path)

print(d[-1])
### BUGGY CODE ###

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

def f(p, n):
  if len(p) == 3:
    global ans
    t = gcd(p[0], p[1])
    t = gcd(t, p[2])
    ans += t
    return t
  for i in range(1, n+1):
    f(p+[i], n)
  
ans = 0
k = int(input())
f([], k)
print(ans)



### FIXED CODE ###

from math import gcd

ans = 0
k = int(input())
for i in range(1, k + 1):
  for j in range(1, k + 1):
    a = gcd(i, j)
    for l in range(1, k + 1):
      ans += gcd(a, l)
print(ans)
### BUGGY CODE ###

s = str(input())
q = int(input())
cnt = 0
for _ in range(q):
    query = list(input().split())
    if query[0] == '1':
        cnt += 1
    else:
        if query[1] == '1':
            if cnt % 2:
                s = s + query[2]
            else:
                s = query[2] + s
        else:
            if cnt % 2:
                s = query[2] + s
            else:
                s = s + query[2]
if cnt % 2:
    s = s[::-1]
print(s)


### FIXED CODE ###

s = str(input())
q = int(input())
cnt = 0
L = []
R = []
for _ in range(q):
    query = list(input().split())
    if query[0] == '1':
        cnt += 1
    else:
        if query[1] == '1':
            if cnt % 2:
                R.append(query[2])
            else:
                L.append(query[2])
        else:
            if cnt % 2:
                L.append(query[2])
            else:
                R.append(query[2])
s = (''.join(L[::-1]) + s + ''.join(R))
if cnt % 2:
    s = s[::-1]
print(s)
### BUGGY CODE ###

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

MOD = 10**9+7
ans = 0

for i in range(60):
    x = 0 # i桁目が1である数の個数
    for j in range(n):
        if a[j]>>i&1: # "a[j]のi桁目が1である"という意味
            x += 1
    now = x*(n-x)%MOD
    for j in range(i):
        now = now*2%MOD # 2**60をかけると容易にオーバーフローするので、安全に2をかけるごとにMODをとっている
    ans += now
    ans %= MOD
    
print(ans)

### FIXED CODE ###

"""
ビット演算, XOR

XORは桁ごとに独立して計算できるので、桁ごとに計算する
XORが1になるのは0と1を足した時。2つの数を足す時、一方の数のi桁目が1でもう一方の数のi桁目が0であれば、2つの数を足した時のi桁目が1になる
全部で数がn個あるとき、i桁目が1の数がx個ある場合は、i桁目が0の数がn-x個あることになるので、x*(n-x)個の組み合わせでi桁目のXORが1になる
"""

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

MOD = 10**9+7
ans = 0

for i in range(60):
    x = 0 # i桁目が1である数の個数
    for j in range(n):
        if a[j]>>i&1: # "a[j]のi桁目が1である"という意味
            x += 1
    now = x*(n-x)%MOD
    for j in range(i):
        now = now*2%MOD # 2**60をかけると容易にオーバーフローするので、安全に2をかけるごとにMODをとっている
    ans += now
    ans %= MOD
    
print(ans)
### BUGGY CODE ###

# 2020-05-22
from collections import deque


def main():
    n, m, k = [int(x) for x in input().split()]
    friends = [set() for _ in range(n)]
    blocks = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        friends[a].add(b)
        friends[b].add(a)
    for _ in range(k):
        a, b = [int(x) - 1 for x in input().split()]
        blocks[a].add(b)
        blocks[b].add(a)

    ansers = []
    ansers_append = ansers.append
    for person in range(n):
        stack = deque()
        stack_append = stack.append
        stack_pop = stack.pop
        stack_append(person)
        link = {person}
        link_add = link.add
        while stack:
            new = stack_pop()
            for adj in friends[new]:
                if adj in link:
                    continue
                stack_append(adj)
                link_add(adj)
        # 友達をたどるとブロック対象に着くことがある。積集合 &。
        ans = len(link) - len(friends[person]) - len(link & blocks[person]) - 1
        ansers_append(ans)
    print(*ansers)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

# 2020-05-22
def main():
    n, m, k = [int(x) for x in input().split()]
    friends = [set() for _ in range(n)]
    blocks = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        friends[a].add(b)
        friends[b].add(a)
    for _ in range(k):
        a, b = [int(x) - 1 for x in input().split()]
        blocks[a].add(b)
        blocks[b].add(a)

    networks = {}  # The dict of networks as sets. Keys are leaders.
    net_leaders = [-1] * n  # The leaders of the networks that the ones joined.
    visited = [False] * n
    for person in range(n):
        if visited[person]:
            continue
        network = set()
        network_add = network.add
        stack = [person]
        stack_append = stack.append
        stack_pop = stack.pop
        while stack:
            new = stack_pop()
            visited[new] = True
            net_leaders[new] = person
            network_add(new)
            for adj in friends[new]:
                if visited[adj]:
                    continue
                stack_append(adj)
        networks[person] = network

    answers = []
    answers_append = answers.append
    for person in range(n):
        net = networks[net_leaders[person]]
        ans = len(net) - len(friends[person]) - 1
        for block in blocks[person]:
            if block in net:
                ans -= 1
        answers_append(ans)

    print(*answers)
    return


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

n = int(input())
a = sorted(list(map(int, input().split())))

A = set(a)
ans = 0

for i in A:
    test = a.count(i)
    if test < i:
        ans += test
    elif test > i:
        ans += test - i
    else:
        pass

print(ans)

### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())))

ans = 0
d = {}

for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

for k,v in d.items():
    if k < v:
        ans += v-k
    elif k > v:
        ans += v
    else:
        pass

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

N = int(input())
S = ["" for i in range(N)]
dict1 = {"key":0}
names =[]
for i in range(N):
    S[i] = input()

for i in range(N):
    if not (S[i] in names):
        names.append(S[i])
        dict1.update({S[i]:1})
    else:
        dict1[S[i]] +=1
max = 0
for i in range(len(names)):
    if max < dict1[names[i]]:
        max = dict1[names[i]]

winners = []

for i in range(len(names)):
    if dict1[names[i]] == max:
        winners.append(names[i])

winners.sort()
for i in range(len(winners)):
    print(winners[i])


### FIXED CODE ###

N = int(input())
S = ["" for i in range(N)]
dict1 = {}
names =[]
for i in range(N):
    S[i] = input()

for i in range(N):
    if not (S[i] in dict1.keys()):
        names.append(S[i])
        dict1.update({S[i]:1})
    else:
        dict1[S[i]] +=1
maxv = 0
for i in range(len(names)):
    if maxv < dict1[names[i]]:
        maxv = dict1[names[i]]

winners = []

for i in range(len(names)):
    if dict1[names[i]] == maxv:
        winners.append(names[i])

winners.sort()
for i in range(len(winners)):
    print(winners[i])
### BUGGY CODE ###

def calc():
  n,m=map(int,input().split())
  s=list(map(int,input().split()))
  t=list(map(int,input().split()))
  dp=[[0]*(m+1) for _ in range(n+1)]
  sum=[[0]*(m+1) for _ in range(n+1)]
  mod=10**9+7
  ans=0
  for i in range(n):
    for j in range(m):
      if s[i]==t[j]:
        dp[i+1][j+1]=(sum[i][j]+1)%mod
      else:
        dp[i+1][j+1]=0
      sum[i+1][j+1]=(sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1])%mod
      ans+=dp[i+1][j+1]
      ans%=mod
  print((ans+1)%mod)
calc()

### FIXED CODE ###

n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0]*m for _ in range(n)]
sum=[[0]*m for _ in range(n)]
mod=10**9+7
for i in range(n):
  if s[i]==t[0]:
    dp[i][0]=1
  else:
    dp[i][0]=0
for i in range(m):
  if t[i]==s[0]:
    dp[0][i]=1
  else:
    dp[0][i]=0
sum[0][0]=dp[0][0]
for i in range(1,n):
  sum[i][0]=sum[i-1][0]+dp[i][0]
for i in range(1,m):
  sum[0][i]=sum[0][i-1]+dp[0][i]
for i in range(1,n):
  for j in range(1,m):
    if s[i]==t[j]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:
      dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
ans=0
for i in range(n):
  for j in range(m):
    ans+=dp[i][j]
    ans=ans%mod
print((ans+1)%mod)
### BUGGY CODE ###

n=int(input())
li=[int(x) for x in input().split()]
from itertools import combinations
l = list(range(n))
s = combinations(l,3)
s=list(s)
d=0
for a,b,c in s:
    if li[a]<(li[b]+li[c]) and li[b]<(li[a]+li[c]) and li[c]<(li[b]+li[a]):
        d=d+1
    else:
        pass
print(d)

### FIXED CODE ###


def findnumberofTriangles(arr): 
	n = len(arr) 
	arr.sort() 
	count = 0
	for i in range(0, n-2):  
		k = i + 2 
		for j in range(i + 1, n):  
			while (k < n and arr[i] + arr[j] > arr[k]): 
				k += 1
			if(k>j): 
				count += k - j - 1

	return count 

n = int(input())
arr=[int(x) for x in input().split()]
print(findnumberofTriangles(arr))
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    path = [-1] * N * 2
    idx = 0
    visited = [False] * N
    cur = 0
    while K:
        if visited[cur]:
            loop = idx - path.index(cur)
            K %= loop
        path[idx] = cur
        visited[cur] = True
        cur = A[cur] - 1
        K -= 1
        idx += 1
    print(cur + 1)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    path = [-1] * N * 2
    idx = 0
    visited = [False] * N
    cur = 0
    loop = -1
    while K:
        K -= 1
        if loop == -1 and visited[cur]:
            loop = idx - path.index(cur)
            K %= loop
        path[idx] = cur
        visited[cur] = True
        cur = A[cur] - 1
        idx += 1
    print(cur + 1)


if __name__ == "__main__":
    main()