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

# Problem E - Crested Ibis vs Monster

# input
H, N = map(int, input().split())
ab_pattern = []
for i in range(N):
    a, b = map(int, input().split())
    ab_pattern.append([a, b])

# initialization
mp_list = [float('INF')] * (H+1)
mp_list[0] = 0

# dp
for i in range(1, H+1):
    for ab in ab_pattern:
        a = ab[0]
        b = ab[1]
        if i-a>=0:
            mp_list[i] = min(mp_list[i], mp_list[i-a] + b)
        else:
            mp_list[i] = min(mp_list[i], mp_list[0] + b)

# output
print(mp_list[H])


### FIXED CODE ###

# ダイナミック・プログラミング
# PythonではTLEを起こしてしまう例

INF = float('inf')

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

for i in range(N):
    a_i, b_i = map(int, input().split())
    A.append(a_i)
    B.append(b_i)

dp = [[INF]*(H+1) for i in range(N+1)] # DP用配列
dp[0][0] = 0 # 初期化処理
for i in range(0,N):
    for j in range(0,H+1):
        a, b = j+A[i], H
        min_h = a
        if a>b:
            min_h = b
        a, b = dp[i+1][j], dp[i][j]
        if a>b:
            dp[i+1][j] = b
        a, b = dp[i+1][min_h], dp[i+1][j]+B[i]
        if a>b:
            dp[i+1][min_h] = b

print(dp[N][H])
### BUGGY CODE ###

N = int(input())
t = [0 for _ in range(81)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in range(1, N+1):
            s = 0
            if int(str(q)[0]) == i and int(str(q)[-1]) == l:
                s += 1
            t[9*(i - 1)+l - 1] += s
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[9*(int(a)-1)+int(a)-1]
    else:
        ans += t[9*(int(b)-1)+int(a)-1]
print(ans)


### FIXED CODE ###

N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())

A = input().split()


def create_all_sub_arrays(A):
    length = len(A)
    return [A[i:j+1] for i in range(length) for j in range(i, length)]


# def find_digits_sum(A):
#     return [sum(list(map(int, s))) for s in A]
#

all_substrings = create_all_sub_arrays(A)
counter = 0

for substring in all_substrings:
    len_s = len(substring)
    digits_sum = sum(list(map(int, substring)))

    if digits_sum % K == len_s:
        counter += 1

print(counter)


### FIXED CODE ###

import itertools
from collections import defaultdict

N, K = map(int, input().split())

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

A = [0] + [x-1 for x in A]

Acum = list(itertools.accumulate(A))
Acum = [x % K for x in Acum]

counter = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K - 1:
        counter[Acum[i - K + 1]] -= 1

print(answer)
### BUGGY CODE ###

n,m = map(int,input().split())
a = {i for i in range(1,n+1)}
for _ in range(m):
  l,r = map(int,input().split())
  temp = list(range(l,r+1))
  a = a.intersection(temp)
print(len(a))


### FIXED CODE ###

n,m = map(int,input().split())
a_min = 1
a_max = n
for _ in range(m):
  l,r = map(int,input().split())
  a_min = max(a_min,l)
  a_max = min(a_max,r)
if a_min>a_max:
  print(0)
else:
  print(a_max-a_min+1)
### BUGGY CODE ###

a = int(input())
sum = 0
for i in range(a):
    sum += i
print(sum)


### FIXED CODE ###

a = int(input())
sum = 0
sum = (a-1)* a // 2
print(sum)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
n = 0
ans = 0
while n < N:
    sum = 0
    for a in A[n:]:
        sum = sum + a
        if sum == 0:
            ans = ans + 1
    n = n + 1
print(ans)

### FIXED CODE ###

import collections

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

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

ans = [0]*(n+1)
res = 0

for i in range(n):
    ans[i+1] = a[i]+ans[i]

col = collections.Counter(ans)

for i in col:
    res += comb2(col[i])

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

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def solve():
	N, Q = MAP()
	ab = [LIST() for _ in range(N-1)]
	tree = defaultdict(list)
	par = [-1]*N
	par[0] = 0
	for a, b in ab:
		tree[a-1].append(b-1)
		tree[b-1].append(a-1)

	def parent(n):
		for child in tree[n]:
			if par[child] == -1:
				par[child] = n
				parent(child)
	parent(0)
	px = [LIST() for _ in range(Q)]

	counter = defaultdict(int)  # まとめる
	for p, x in px:
		counter[p-1] += x

	ans = [-1] * N  # 答え入れる
	ans[0] = counter[0]

	def DFS(n):
		if n != 0:
			ans[n] = counter[n] + ans[par[n]]
		for child in tree[n]:
			if ans[child] == -1:
				DFS(child)

	DFS(0)
	print(*ans, sep=" ")

if  __name__ == "__main__":
	solve()


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def solve():
	N, Q = MAP()
	ab = [LIST() for _ in range(N-1)]
	tree = defaultdict(list)
	par = [-1]*N
	par[0] = 0
	for a, b in ab:
		tree[a-1].append(b-1)
		tree[b-1].append(a-1)
		par[b-1] = a-1

	px = [LIST() for _ in range(Q)]

	ans = [0] * N  # 答え入れる

	for p, x in px:
		ans[p-1] += x

	
	for i in range(1, N):
		ans[i] += ans[par[i]]

	print(*ans, sep=" ")

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

import bisect
N , M = map(int,input().split())
A = [int(i) for i in input().split()]
A.sort()
for _ in range(M):
    a = A.pop(-1) >> 1
    A.insert(bisect.bisect_left(A,a),a)
print(sum(A))


### FIXED CODE ###

import heapq

N , M = map(int,input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    a = -heapq.heappop(A) >> 1
    heapq.heappush(A,-a)
print(-sum(A))
### BUGGY CODE ###

N = int(input())
A = input().split(" ")
result = 1
for i in range(N):
  result *= int(A[i])
if result > 10**18:
  print(-1)
else:
  print(result)

### FIXED CODE ###

N = int(input())
A = input().split(" ")
result = 1
if "0" in A:
  print(0)
  exit()
else:
  for i in range(N):
    result *= int(A[i])
    if result > 10**18:
      print(-1)
      exit()
print(result)
### BUGGY CODE ###

from bisect import bisect_left,bisect
n = int(input())
s = list(input())
q = int(input())
al=[[] for i in range(26)]
for i in range(n):
    al[ord(s[i])-97].append(i)
ans = []
for i in range(q):
    a , b , x = input().split()
    if a == "1":
        al[ord(s[int(b)-1])-97].pop(bisect_left(al[ord(s[int(b)-1])-97],int(b)-1))
        al[ord(x)-97].insert(bisect_left(al[ord(x)-97],int(b)-1),int(b)-1)
        s[int(b)-1] = x
    elif a == "2":
        b = int(b)-1
        x = int(x)-1
        cou = 0
        for j in range(26):
            l = bisect_left(al[j],b)
            r = bisect(al[j],x)
            if l != r:
                cou += 1
        ans.append(cou)
for i in ans:
    print(i)

### FIXED CODE ###

def main():
    from bisect import bisect_left,bisect
    n = int(input())
    s = list(input())
    q = int(input())
    al=[[] for i in range(26)]
    for i in range(n):
        al[ord(s[i])-97].append(i)
    ans = []
    for i in range(q):
        a , b , x = input().split()
        if a == "1":
            al[ord(s[int(b)-1])-97].pop(bisect_left(al[ord(s[int(b)-1])-97],int(b)-1))
            al[ord(x)-97].insert(bisect_left(al[ord(x)-97],int(b)-1),int(b)-1)
            s[int(b)-1] = x
        elif a == "2":
            b = int(b)-1
            x = int(x)-1
            cou = 0
            for j in range(26):
                l = bisect_left(al[j],b)
                r = bisect(al[j],x)
                if l != r:
                    cou += 1
            ans.append(cou)
    for i in ans:
        print(i)

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

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

diff_dic = {}
diff_dic[('R', 'G')] = []
diff_dic[('R', 'B')] = []
diff_dic[('G', 'R')] = []
diff_dic[('G', 'B')] = []
diff_dic[('B', 'G')] = []
diff_dic[('B', 'R')] = []

for i in range(N):
    for j in range(i + 1, N):

        if S[i] == 'R':
            if S[j] != 'R':
                diff_dic[('R', S[j])].append((i, j - i))

        if S[i] == 'G':
            if S[j] != 'G':
                diff_dic[('G', S[j])].append((i, j - i))

        if S[i] == 'B':
            if S[j] != 'B':
                diff_dic[('B', S[j])].append((i, j - i))

cnt = 0
for i in range(N):
    if S[i] == 'R':
        for j, d in diff_dic[('G', 'B')]:
            if j > i and (j - i) != d:
                cnt += 1

        for j, d in diff_dic[('B', 'G')]:
            if j > i and (j - i) != d:
                cnt += 1

    if S[i] == 'G':
        for j, d in diff_dic[('R', 'B')]:
            if j > i and (j - i) != d:
                cnt += 1

        for j, d in diff_dic[('B', 'R')]:
            if j > i and (j - i) != d:
                cnt += 1

    if S[i] == 'B':
        for j, d in diff_dic[('R', 'G')]:
            if j > i and (j - i) != d:
                cnt += 1

        for j, d in diff_dic[('G', 'R')]:
            if j > i and (j - i) != d:
                cnt += 1

print(cnt)


### FIXED CODE ###

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

diff_dic = {}
diff_dic[('R', 'G')] = []
diff_dic[('R', 'B')] = []
diff_dic[('G', 'R')] = []
diff_dic[('G', 'B')] = []
diff_dic[('B', 'G')] = []
diff_dic[('B', 'R')] = []

R_lst = [0] * N
G_lst = [0] * N
B_lst = [0] * N

r_cnt = 0
g_cnt = 0
b_cnt = 0

cnt = 0
for i in range(N):
    if S[i] == 'R':
        r_cnt += 1
    elif S[i] == 'G':
        g_cnt += 1
    else:
        b_cnt += 1

    R_lst[i] = r_cnt
    G_lst[i] = g_cnt
    B_lst[i] = b_cnt

    for j in range(i):
        d = i - j
        if (S[i] == 'R' and S[j] == 'G') or (S[i] == 'G' and S[j] == 'R'):
            if j - 1 >=0 and B_lst[j - 1] > 0:
                cnt += B_lst[j - 1]
                if j - d >= 0 and S[j - d] == 'B':
                    cnt -= 1

        if (S[i] == 'G' and S[j] == 'B') or (S[i] == 'B' and S[j] == 'G'):
            if j - 1 >=0 and R_lst[j - 1] > 0:
                cnt += R_lst[j - 1]
                if j - d >= 0 and S[j - d] == 'R':
                    cnt -= 1

        if (S[i] == 'B' and S[j] == 'R') or (S[i] == 'R' and S[j] == 'B'):
            if j - 1 >= 0 and G_lst[j - 1] > 0:
                cnt += G_lst[j - 1]
                if j - d >= 0 and S[j - d] == 'G':
                    cnt -= 1

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

import collections
s = list(input())
Ans = 0
c = collections.Counter(s)
d = c['B']
for i in range(len(s)):
    if s[i] == 'B':
        for j in range(len(s)-i-1):
            if s[i+j+1]=='W':
                Ans += j+1
                s[i] = 'W'
                s[i+1] = 'B'
                s[i+j+1] = 'B'
                break
    if i == d:
        break
print(Ans)

### FIXED CODE ###

s = list(input())
Ans = 0
W_put_place = 0
for i in range(len(s)):
    if s[i] == 'W':
        Ans += i - W_put_place
        W_put_place += 1
print(Ans)
### BUGGY CODE ###

def froyd(n, d):
    for k in range(n):
        for s in range(n):
            ds = d[s]
            for t in range(n):
                ds[t] = min(ds[t], ds[k] + d[k][t])


def main():
    N, M, L = [int(x) for x in input().split()]
    INF = float("inf")
    A = [[] for _ in range(N)]
    B = [[] for _ in range(N)]
    for i in range(N):
        A[i] = [INF] * N
        A[i][i] = 0
        B[i] = [INF] * N
        B[i][i] = 0
    for i in range(M):
        a, b, c = [int(x) for x in input().split()]
        A[a - 1][b - 1] = c
        A[b - 1][a - 1] = c
    froyd(N, A)
    # print(A)
    for s in range(N):
        for t in range(N):
            B[s][t] = 0 if s == t else 1 if A[s][t] <= L else INF
    # print(B)
    froyd(N, B)
    # print(B)

    Q = int(input())
    for _ in range(Q):
        s, t = [int(x) for x in input().split()]
        b = B[s - 1][t - 1] - 1
        print(-1 if b == INF else b)


main()


### FIXED CODE ###

def froyd(n, d):
    for k in range(n):
        for s in range(n):
            ds = d[s]
            for t in range(n):
                ds[t] = min(ds[t], ds[k] + d[k][t])


def main():
    N, M, L = [int(x) for x in input().split()]
    INF = float("inf")
    A = [[] for _ in range(N)]
    B = [[] for _ in range(N)]
    for i in range(N):
        A[i] = [INF] * N
        A[i][i] = 0
        B[i] = [INF] * N
        B[i][i] = 0
    for i in range(M):
        a, b, c = [int(x) for x in input().split()]
        A[a - 1][b - 1] = c
        A[b - 1][a - 1] = c
    froyd(N, A)
    # print(A)
    for s in range(N):
        for t in range(N):
            B[s][t] = 0 if s == t else 1 if A[s][t] <= L else INF
    # print(B)
    froyd(N, B)
    # print(B)

    Q = int(input())
    for _ in range(Q):
        s, t = [int(x) for x in input().split()]
        b = B[s - 1][t - 1] - 1
        print(-1 if b == INF else b)


main()
### BUGGY CODE ###

N = int(input())
H = list(map(int, input().split())) + [10**9 + 10]
check = 0
ans = [0]

for i in range(1, N + 1):
    if H[i - 1] >= H[i]:
        check += 1
    else:
        if min(ans) < check:
            ans.append(check)
            check = 0

print(max(ans))

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split())) + [10**9 + 10]
check = 0
ans = [0]

for i in range(1, N + 1):
    if H[i - 1] >= H[i]:
        check += 1
    else:
        if min(ans) < check:
            ans.append(check)
            check = 0

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

import numpy as np
from collections import deque

H, W = list(map(int, input().split()))
s_y, s_x = 0, 0
g_y, g_x = H - 1, W - 1
visited = np.full((H, W), False)
board = np.zeros((H, W))
queue = deque()

for i in range(H):
    row = input()
    for j, r in enumerate(row):
        if r == '#':
            board[i][j] = 1
            visited[i][j] = True
            queue.append(((i, j), 0))

direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
while len(queue) > 0:
    (y, x), dist = queue.popleft()
    for dx, dy in direction:
        new_y, new_x = y + dy, x + dx
        if new_y < 0 or new_y >= H or new_x < 0 or new_x >= W:
            continue
        if board[new_y][new_x] == 1:
            continue
        if visited[new_y][new_x]:
            continue
        queue.append(((new_y, new_x), dist + 1))
        visited[new_y][new_x] = True
print(dist)


### FIXED CODE ###

def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    H, W = map(int, input().split())
    edge = ['#'] * (W + 2)
    field = [edge]
    q = deque()

    for i in range(H):
        line = input()
        field.append(['#'] + list(line) + ['#'])
        for j in range(W):
            if line[j] == '#':
                q.append((i + 1, j + 1, 0))
    field.append(edge)
    res = 0

    while q:
        y, x, lv = q.popleft()
        if lv > res:
            res = lv

        if field[y + 1][x] == '.':
            field[y + 1][x] = '#'
            q.append((y + 1, x, lv + 1))

        if field[y - 1][x] == '.':
            field[y - 1][x] = '#'
            q.append((y - 1, x, lv + 1))

        if field[y][x + 1] == '.':
            field[y][x + 1] = '#'
            q.append((y, x + 1, lv + 1))

        if field[y][x - 1] == '.':
            field[y][x - 1] = '#'
            q.append((y, x - 1, lv + 1))

    print(res)

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

N,Q=map(int,input().split())
Ss=[i for i in input()]
#S = input()
for i in range(Q):
    l,r = map(int,input().split())
    count = 0
    Sscopy = Ss[l-1:r]
    for j in range(len(Sscopy)-1):
        if Sscopy[j]=="A"and Sscopy[j+1]=="C":
            count+=1
    print(count)

### FIXED CODE ###

N,Q=map(int,input().split())
Ss=[i for i in input()]
counterlist=[0]*N
for s in range(len(Ss)-1):
    if Ss[s]=="A" and Ss[s+1]=="C":
        counterlist[s+1]=1
for c in range(len(counterlist)-1):
    counterlist[c+1]+=counterlist[c]
for i in range(Q):
    l,r = map(int,input().split())
    print(counterlist[r-1]-counterlist[l-1])
### BUGGY CODE ###

import sys


def alg_combination(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i)
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i)
        return denominator // molecule


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    mt = 0
    mn = 0
    for i in range(n):
        t = alg_combination(a[-1], a[i])
        if t > mt:
            mn = a[i]
            mt = t
    print(a[-1], mn)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    c = 0
    for i in range(n):
        if c < min(a[i], abs(a[-1] - a[i])):
            c = a[i]
    print(a[-1], c)


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

n,k,q = map(int, input().split())
nl = [k]*n

a = []
for i in range(q):
    a.append(int(input()))
for j in a:
    nl = list(map(lambda x: x - 1, nl))
    nl[j-1] += 1
for k in range(n):
    if nl[k] > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n,k,q = map(int, input().split())
nl = [k - q]*n
a = []
for i in range(q):
    a.append(int(input()))
for j in a:
    nl[j-1] += 1
for k in range(n):
    if nl[k] > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

n = int(input())

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

for j in range(n):
  for i in range(n):
    
    if a[i] == j+1:
      print(i+1, end=' ')

### FIXED CODE ###

n = int(input())

a = list(map(int, input().split()))
b = list(enumerate(a))
c = sorted(b, key=lambda x:x[1])


print(*[c[i][0]+1 for i in range(n)])
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
was = []
place = 1
cnt = 0

while place not in was:
  if cnt < K:
    was.append(place)
    place = A[place-1]
    cnt += 1
  else:
    print(place)
    break;
else:
  loop = cnt - was.index(place)
  num = (K-cnt) % loop + was.index(place)
  print(was[num])

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
was = []
tf = [False] * N
place = 1
cnt = 0

while tf[place-1] == False:
  if cnt < K:
    tf[place-1] = True
    was.append(place)
    place = A[place-1]
    cnt += 1
  else:
    print(place)
    break;
else:
  loop = cnt - was.index(place)
  num = (K-cnt) % loop + was.index(place)
  print(was[num])
### BUGGY CODE ###

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

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

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
for i in range(1,N+1):
    print(c[i])
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7

for i in range(n-1):
    ans += a[i]*sum(a[i+1::])

print(ans%mod)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
s = sum(a)
ans = 0
mod = 10**9+7

for i in range(n-1):
    s -= a[i]
    ans += a[i]*s

print(ans%mod)
### BUGGY CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
H, W = list(map(int, input().split()))
L = [[True if j == "#" else False for j in input()] for i in range(H)]
blacks = [[i, j] for i in range(H) for j in range(W) if L[i][j]]
black_count = len(blacks)

cands = [[-1, 0], [1, 0], [0, -1], [0, 1]]
all_count = H * W
result = 0
while black_count < all_count:
  next_steps = list(set([(black[0]+cand[0], black[1]+cand[1]) for black in blacks for cand in cands]))
  blacks = [[i,j] for i, j in next_steps if i >= 0 and i < H and j >= 0 and j < W and not L[i][j]]
  for i, j in blacks:
    L[i][j] = True
  black_count += len(blacks)
  result += 1

print(result)


### FIXED CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
from collections import deque
import copy

def main():
  H, W = list(map(int, input().split()))
  L = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if L[i][j]])
  cands = [(0, -1), (0, 1), (-1, 0), (1, 0)]
  result = 0
  while True:
    nq = deque()
    while q:
      i, j = q.popleft()
      if i > 0 and not L[i-1][j]:
        L[i-1][j] = True
        nq.append((i-1, j))
      if j > 0 and not L[i][j-1]:
        L[i][j-1] = True
        nq.append((i, j-1))
      if i < H-1 and not L[i+1][j]:
        L[i+1][j] = True
        nq.append((i+1, j))
      if j < W-1 and not L[i][j+1]:
        L[i][j+1] = True
        nq.append((i, j+1))
    if nq:
      q = copy.copy(nq)
    else:
      break    
    result += 1
  print(result)

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

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
a = list( map(int, input().split()))
a_modm=[ai%m for ai in a]

from itertools import accumulate
B = [0] + a_modm
B = list(accumulate(B))
ans = 0
for i in range(0,n):
    for j in range(i,n):
        if (B[j+1]-B[i])%m == 0:
            ans+=1

print(ans)


### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

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

from itertools import accumulate
b = [0] + a
b = list(accumulate(b))

count_mod = defaultdict(int)

for i in range(n+1):
    bi_modm = b[i]%m
    if count_mod[bi_modm] is None: count_mod[bi_modm]=1
    else: count_mod[bi_modm] += 1

ans = 0
for count in count_mod.values():
    ans += count*(count-1)//2
print(ans)
### BUGGY CODE ###

import numpy as np

N,K = list(map(int, input().split()))
LRs = [list(map(int, input().split())) for _ in range(K)]

dp = np.zeros(N*2+2, dtype = int)
dp[1] = 1

for i in range(1, N+1):
    atai = dp[i]
    for LR in LRs:
#        p_array = ([atai] * (LR[1] - LR[0] + 1))
#        mae_zero = ([0] * (LR[0] + (i - 1) + 1))
#        usiro_zero = ([0] * (N*2 - (i - 1) - LR[1]))

        mae_zero = np.zeros(LR[0] + i , dtype = int)
        usiro_zero = np.zeros(N*2 - (i - 1) - LR[1], dtype = int)
        p_array = np.full((LR[1] - LR[0] + 1), atai, dtype = int)

        tasu_array = np.block([mae_zero, p_array, usiro_zero])
        dp = (dp + tasu_array) % 998244353

print(dp[N] % 998244353)

### FIXED CODE ###

import numpy as np

N,K = list(map(int, input().split()))
LRs = [list(map(int, input().split())) for _ in range(K)]

dp = np.zeros(N+2, dtype = int)
dp[1] = 1
dp[2] = -1

atai = 0
for i in range(1, N+2):
    atai += dp[i]
    for LR in LRs:
        if(i+LR[0] <= N):
            dp[i+LR[0]] = (dp[i+LR[0]] + atai) % 998244353
        if(i+LR[1] <= N):
            dp[i+LR[1]+1] = (dp[i+LR[1]+1] -atai) % 998244353

#    print(dp)

#復元
ruisekiwa = [0]

for hoge in dp:
    ruisekiwa.append(ruisekiwa[-1]+hoge)
print(ruisekiwa[N+1] % 998244353)
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(n-1,0,-1):
  ans += i%(i+1)
print(ans)  
     
  
  


### FIXED CODE ###

n = int(input())
ans = (n-1)*n//2
print(ans)