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

import numpy as np


def func(cnt, cn):
    tmp = [0] * 13
    for i in range(13):
        nn = (cn + i) % 13
        tmp[nn] = cnt[i]
    return tmp


MOD = 10**9+7

s = list(input())
s.reverse()

cnt = np.zeros(13, dtype=np.int64)
cnt[0] = 1
t = 1
for ci in range(len(s)):
    t %= 13 
    if s[ci] != '?':
        cn = int(s[ci]) * t % 13
        cnt = func(cnt, cn)
    else:
        tmp = np.zeros(13, dtype=np.int64)
        for cj in range(10):
            cn = cj * t % 13
            tmp += func(cnt, cn)
            tmp %= MOD
        cnt = tmp
    t *= 10
print(cnt[5])

### FIXED CODE ###

def func(cnt, cn):
    tmp = [0] * 13
    for i in range(13):
        nn = (cn + i) % 13
        tmp[nn] = cnt[i]
    return tmp


MOD = 10**9+7

s = list(input())
s.reverse()

cnt = [0]*13
cnt[0] = 1
t = 1
for ci in range(len(s)):
    t %= 13 
    if s[ci] != '?':
        cn = int(s[ci]) * t % 13
        cnt = func(cnt, cn)
    else:
        tmp = [0]*13
        add = [0]*13
        for cj in range(10):
            cn = cj * t % 13
            add = func(cnt, cn)
            for _ in range(13):
                tmp[_] += add[_]
                tmp[_] %= MOD
        cnt = tmp
    t *= 10
print(cnt[5])
### BUGGY CODE ###

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

from fractions import gcd
# def gcd(x, y):
#     if x < y: x, y = y, x
#     while y != 0:
#         x, y = y, x % y
#     return x

gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = {}
    if n % 2 == 0:
        divisor[2] = 1
        # if 2 in divisor:
        #     divisor[2] += 1
        # else:
        #     divisor[2] = 1
        # n //= 2

    i = 3
    while i <= n:
        while n % i == 0:
            if i in divisor:
                divisor[i] += 1
            else:
                divisor[i] = 1
            n //= i
        i += 2
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)




### FIXED CODE ###

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

from fractions import gcd
from collections import Counter
# def gcd(x, y):
#     if x < y: x, y = y, x
#     while y != 0:
#         x, y = y, x % y
#     return x

gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = Counter()
    while n % 2 == 0:
        divisor[2] += 1
        n //= 2
        
    i = 3
    while i*i <= n:
        while n % i == 0:
            divisor[i] += 1
            n //= i
        i += 2
    if n > 1:
        divisor[n] += 1
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)
### BUGGY CODE ###

def run():
  N, W = map(int, input().split())
  wv_li = [tuple(map(int, input().split())) for n in range(N)]
  dp = [[0]*N for w in range(W+1)]
  for w in range(W+1):
    for n in range(N):
      pre_w = max(-1, w-wv_li[n][0])
      if pre_w < 0: dp[w][n] = dp[w][n-1]
      else: dp[w][n] = max(dp[w][n-1], dp[pre_w][n-1] + wv_li[n][1])
  print(max(dp[-1]))
  
if __name__ == '__main__':
  run()

### FIXED CODE ###

def run():
  N, W = map(int, input().split())
  wv_li = [[0, 0]]+[list(map(int, input().split())) for n in range(N)]
  dp = [[0]*(N+1) for w in range(W+1)]
  #print(wv_li)
  #print(dp)
  for w in range(1, W+1):
    for n in range(1, N+1):
      wn, vn = wv_li[n]
      if w < wn:
        dp[w][n] = dp[w][n-1]
      else:
        dp[w][n] = max(dp[w][n-1], dp[w-wn][n-1]+vn)
  print(dp[W][N])
      
  
if __name__ == '__main__':
  run()
### BUGGY CODE ###

mod = 998244353


def pow(a, b):
    ans = 1
    for i in range(b):
        ans = ((ans % mod) * (a % mod)) % mod
    return ans


def sum_mod(v):
    ans = 0
    for i in range(1, len(v)):
        ans = (ans + v[i]) % mod
    return ans


n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
A = sum(a)

dp = [[0 for _ in range(A+1)] for _ in range(n+1)]
dp2 = [[0 for _ in range(A+1)] for _ in range(n+1)]
dp[0][0] = 1
dp2[0][0] = 1
for t in range(1, n+1):
    for r in range(0, A+1):
        dp[t][r] = dp[t-1][r] * 2 % mod
        dp2[t][r] = dp2[t-1][r] % mod
        if r - a[t-1] >= 0:
            dp[t][r] = (dp[t][r] + dp[t-1][r-a[t-1]]) % mod
            dp2[t][r] = (dp2[t][r] + dp2[t-1][r-a[t-1]]) % mod
# print(dp)

ans = pow(3, n)
for r in range((A + 1) // 2, A+1):
    ans -= dp[n][r] * 3
    ans %= mod
    ans += mod
    ans %= mod
if A % 2 == 0:
    ans = (ans + dp2[n][A // 2] * 3) % mod
print(ans)

### FIXED CODE ###

import numpy as np

mod = 998244353


def sum_mod(v):
    ans = 0
    for i in range(1, len(v)):
        ans = (ans + v[i]) % mod
    return ans


n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
A = sum(a)

dp = np.zeros((n + 1, A + 1), dtype=int)
dp2 = np.zeros((n + 1, A + 1), dtype=int)
dp[0][0] = 1
dp2[0][0] = 1
for t in range(1, n + 1):
    dp[t, :] = dp[t - 1, :] * 2 % mod
    dp2[t, :] = dp2[t - 1, :] % mod
    dp[t, a[t - 1]:] += dp[t - 1, :-a[t - 1]] % mod
    dp2[t, a[t - 1]:] += dp2[t - 1, :-a[t - 1]] % mod
#print(dp)

ans = 3 ** n % mod
ans -= np.sum(dp[n][(A + 1) // 2:]) * 3 % mod
if A % 2 == 0:
    ans += dp2[n][A // 2] * 3 % mod
print(ans % mod)
### BUGGY CODE ###

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,k = iim()
A = iil()
'''
A = [0]*200000
上記でtryしても41回で全て明るさ200000になる
'''

def imos(l):
    n = len(l)
    tmp = [0]*n
    for i,item in enumerate(l):
        l = max(0,i-item)
        r = min(n-1,i+item)
        tmp[l] += 1
        if r+1 < n:
            tmp[r+1] -= 1
    for i in range(1,n):
        tmp[i] += tmp[i-1]
    return tmp

for _ in range(min(k,50)):
    A = imos(A)
#    print(_,min(A))

print(*A)

### FIXED CODE ###

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,k = iim()
A = iil()
'''
A = [0]*200000
上記でtryしても41回で全て明るさ200000になる
'''

def imos(l):
    n = len(l)
    tmp = [0]*n
    for i,item in enumerate(l):
        l = max(0,i-item)
        r = min(n-1,i+item)
        tmp[l] += 1
        if r+1 < n:
            tmp[r+1] -= 1
    for i in range(1,n):
        tmp[i] += tmp[i-1]
    return tmp

for _ in range(min(k,100)):
    A = imos(A)
#    print(_,min(A))

print(*A)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
buka_num=[0 for _ in range(N+1)]

for i in range(N-1):
  num = a.pop(0)
  buka_num[num]+=1

buka_num.pop(0)
buka_str = [str(n) for n in buka_num]
joined = "\n".join(buka_str)
print(joined)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
buka_num=[0 for _ in range(N+1)]

for i in a:
  buka_num[i]+=1
buka_num.pop(0)
for j in buka_num:
  print(j)
### BUGGY CODE ###

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

S = []
for i in range(N):
    S.append(sum(range(p[i]+1))/p[i])

DP = [0 for i in range(N+1)]
SS = sum(S[:K])

for i in range(K):
    DP[i] = SS
# print(DP)
for i in range(K,N):
    DP[i] = DP[i-1]-S[i-K]+S[i]
# print(S)
# print(DP)
print(max(DP))

### FIXED CODE ###

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

S = []
for i in range(N):
    S.append(sum(range(p[i]+1))/p[i])

DP = [0 for i in range(N+1)]
SS = sum(S[:K])

for i in range(K):
    DP[i] = SS
# print(DP)
for i in range(K,N):
    DP[i] = DP[i-1]-S[i-K]+S[i]
# print(S)
# print(DP)
print(max(DP))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if min(P[:i+1]) >= P[i]:
        cnt += 1
print(cnt)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
P = list(map(int, input().split()))
cnt = 0
low = 200001
for i,p in enumerate(P):
    if p < low:
        low = p
    if p <= low:
        cnt += 1
print(cnt)
### BUGGY CODE ###

n = int(input())

def gcd(a,b):
    while b:
        a, b = b, a % b
    return a

ans = 0
if n == 1:
    ans = 1
else:
    for i in range(n):
        i = i + 1
        #ans = ans + i #(i,i,i)
        for j in range(n):
            j = j + 1
            for k in range(n):
                k = k + 1
                ij = gcd(i,j)
                ans = ans + gcd(ij,k)

print(ans)


### FIXED CODE ###

n = int(input())

def gcd(a,b):
    while b:
        a, b = b, a % b
    return a

ans = 0
if n == 1:
    ans = 1
else:
    for i in range(n):
        i = i + 1
        #ans = ans + i #(i,i,i)
        for j in range(n):
            j = j + 1
            for k in range(n):
                k = k + 1
                ij = gcd(i,j)
                ans = ans + gcd(ij,k)

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

def main():
    import sys
    from collections import defaultdict
    N, M, K = map(int, sys.stdin.readline().split())

    F = [set() for _ in range(N)]
    B = [set() for _ in range(N)]
    for m in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a - 1, b - 1
        F[a].add(b)
        F[b].add(a)

    for k in range(K):
        c, d = map(int, sys.stdin.readline().split())
        c, d = c - 1, d - 1
        B[c].add(d)
        B[d].add(c)

    D = defaultdict(set)
    parents = [-1] * N
    visited = set()
    for s in range(N):
        if s in visited:
            continue

        stack = [s]
        D[s].add(s)
        while stack:
            n = stack.pop()
            visited.add(n)
            parents[n] = s
            for to in F[n]:
                if to in visited:
                    continue
                D[s].add(to)
                stack.append(to)

    #print(1 / 0)
    ans = [0] * N
    #print(D)
    for i in range(N):
        #print(D[parents[i]] - F[i] - B[i] - {i}, F[i], B[i])
        ans[i] = len(D[parents[i]] - F[i] - B[i] - {i})

    print(*ans, sep=' ')


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    from collections import defaultdict
    N, M, K = map(int, sys.stdin.readline().split())

    F = [set() for _ in range(N)]
    B = [set() for _ in range(N)]
    for m in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a - 1, b - 1
        F[a].add(b)
        F[b].add(a)

    for k in range(K):
        c, d = map(int, sys.stdin.readline().split())
        c, d = c - 1, d - 1
        B[c].add(d)
        B[d].add(c)

    D = defaultdict(set)
    parents = [-1] * N
    visited = set()
    for s in range(N):
        if s in visited:
            continue

        stack = [s]
        D[s].add(s)
        while stack:
            n = stack.pop()
            visited.add(n)
            parents[n] = s
            for to in F[n]:
                if to in visited:
                    continue
                D[s].add(to)
                stack.append(to)

    ans = [0] * N
    for i in range(N):
        X = D[parents[i]]
        tmp_ans = 0
        tmp_ans += len(X)
        tmp_ans -= len(F[i])
        tmp_ans -= 1
        for b in B[i]:
            if b in X:
                tmp_ans -= 1
        ans[i] = tmp_ans

    print(*ans, sep=' ')


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

import numpy as np
MOD = 10 ** 9 + 7

dp = np.zeros(13, dtype = np.int64)
dp[0] = 1

move = np.arange(0,52,4) % 13
ten = np.ones(10, dtype=np.int64)
for s in input():
  dp = dp[move]
  if s == '?':
    dp = np.convolve(dp, ten)
    dp[:9] += dp[13:22]
    dp %= MOD
  else:
    s = int(s)
    dp = np.concatenate([dp[13-s:13],dp[:13-s]])
  
print(dp[5])


### FIXED CODE ###

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

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])
### BUGGY CODE ###

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

mod = 10 ** 9 + 7
ans = 0
for j in range(n):
    for i in range(j):
        tmp = A[i]*A[j] % mod
        ans = (ans+tmp) % mod
print(ans)

### FIXED CODE ###

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

mod = 10 ** 9 + 7

summ = 0
quadsum = 0

for k in range(n):
    summ = (summ + A[k]) % mod
    quadsum = (quadsum + A[k]*A[k])%mod

ans = (summ*summ)%mod - quadsum
if ans % 2 == 1:
    ans += mod
ans = (ans/2)%mod
print(int(ans))
### BUGGY CODE ###

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

mod = 998244353

dp = [[0] * n for _ in range(3000 + 1)]
dp2 = [[0] * n for _ in range(3000 + 1)]

# init
dp[a[0]][0] = 1
dp2[a[0]][0] = 1

for i in range(1, s + 1):
    for j in range(1, n):
        if i == a[j]:
            dp[i][j] = dp[i][j-1] + j + 1
        elif i - a[j] > 0:
            dp[i][j] = dp[i][j-1] + dp[i - a[j]][j - 1]
        else:
            dp[i][j] = dp[i][j-1]

        dp2[i][j] = dp2[i][j-1] + dp[i][j]


ans = 0
for j in range(n):
    ans += dp[s][j]

print(ans % mod)


### FIXED CODE ###

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

mod = 998244353

dp = [[0] * n for _ in range(3000 + 1)]

# init
dp[a[0]][0] = 1

for i in range(1, s + 1):
    for j in range(1, n):
        if i == a[j]:
            dp[i][j] = (dp[i][j-1] + j + 1) % mod
        elif i - a[j] > 0:
            dp[i][j] = (dp[i][j-1] + dp[i - a[j]][j - 1]) % mod
        else:
            dp[i][j] = dp[i][j-1] % mod



ans = 0
for j in range(n):
    ans += dp[s][j]

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

# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 1
    A.sort()
    for a in A:
        ans *= a

    if ans > 10**18:
        return -1
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 1
    l = 10**18
    A.sort()
    for a in A:
        ans *= a
        if ans > l:
            return -1
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


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

s = list(input())
cnt = 0
while len(set(s)) == 2:
  for i in range(len(s)):
    if s[i] != s[i+1]:
      cnt += 1
      s = s[:i] + s[i+2:]
      break

print(cnt * 2)

### FIXED CODE ###

s = list(input())

zerocnt = s.count('0')
onecnt = len(s) - zerocnt
if zerocnt <= onecnt:
  print(zerocnt * 2)
else:
  print(onecnt * 2)
### BUGGY CODE ###

s = input()
q = int(input())


def s_add(r, f):
    if r % 2 == 0:
        if f == 1:
            return True
        else:
            return False
    else:
        if f == 1:
            return False
        else:
            return True


cnt = 0
for _ in range(q):
    query = input()
    if query == "1":
        cnt += 1
    else:
        z, f, c = query.split()
        if s_add(cnt, int(f)):
            s = c + s
        else:
            s += c

if cnt % 2 == 0:
    print(s)
else:
    print(s[::-1])


### FIXED CODE ###

s = input()
q = int(input())
left = ""
right = ""


def s_add(r, f):
    if r % 2 == 0:
        if f == 1:
            return True
        else:
            return False
    else:
        if f == 1:
            return False
        else:
            return True


cnt = 0
for _ in range(q):
    query = input()
    if query == "1":
        cnt += 1
    else:
        z, f, c = query.split()
        if s_add(cnt, int(f)):
            left += c
        else:
            right += c

if cnt % 2 == 0:
    print(left[::-1] + s + right)
else:
    print(right[::-1] + s[::-1] + left)
### BUGGY CODE ###

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

for i in range(m//n,0,-1):
    if m%i==0:
        print(i)
        break


### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n,m=map(int,input().split())
ans=1
for i in make_divisors(m):
    if i>=n:
        ans=max(ans,m//i)
print(ans)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc094/tasks/arc095_a
# C - Many Medians
import copy

n = int(input().split()[0])
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
mean_index = int((n + 1)/ 2) - 1
mean_list = []

index_list = [sorted_x_list.index(x) for x in x_list]

for index in index_list:
    if index < n - 1:
        w_list = sorted_x_list[:index] + sorted_x_list[index+1:]
    else:
        w_list = sorted_x_list[:index]

    mean_value = w_list[mean_index]
    mean_list.append(str(mean_value))

ans = '\n'.join(mean_list)
print(ans)

### FIXED CODE ###

# https://atcoder.jp/contests/abc094/tasks/arc095_a
# C - Many Medians
import copy

n = int(input().split()[0])
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
mean_index = int((n + 1)/ 2) - 1
mean_list = []

a = sorted_x_list[mean_index]
b = sorted_x_list[mean_index + 1]
for x in x_list:
    if x <= a:
        mean_list.append(str(b))
    else:
        mean_list.append(str(a))

ans = '\n'.join(mean_list)
print(ans)
### BUGGY CODE ###

from itertools import combinations

def main():
    EPS = 1e-8

    N, K, *XYC = map(int, open(0).read().split())
    PC = [(complex(x, y), c) for x, y, c in zip(*[iter(XYC)] * 3)]


    def intersection(A, r, B, s):
        D = B - A
        d = abs(D)

        cos_t = (d * d + r * r - s * s) / (2 * d * r)
        sin_t = max(1 - cos_t * cos_t, 0.0) ** 0.5

        R = r * complex(cos_t, sin_t)
        D /= d

        return (
            A + D * R,
            A + D * R.conjugate(),
        )


    def is_ok(T):
        A = [p for p, _ in PC]
        for (p1, c1), (p2, c2) in combinations(PC, 2):
            A += intersection(p1, T / c1, p2, T / c2)

        return any(K <= sum(1 for p, c in PC if c * abs(a - p) < T + EPS) for a in A)


    ng, ok = 0, 1000000
    for _ in range(100):
        md = (ng + ok) / 2
        if is_ok(md):
            ok = md
        else:
            ng = md

    print(ok)

main()

### FIXED CODE ###

from math import hypot
from collections import deque

N, K, *XYC = map(int, open(0).read().split())
XYC = list(zip(*[iter(XYC)] * 3))

Q = deque([(0, 0, 1000.0)])

ans = float("inf")
while Q:
    X, Y, r = Q.popleft()
    if ans * 0.9999995 > sorted(c * hypot(max(abs(X - x) - r, 0), max(abs(Y - y) - r, 0)) for x, y, c in XYC)[K - 1]:
        ans = min(ans, sorted(c * hypot(X - x, Y - y) for x, y, c in XYC)[K - 1])
        for dx, dy in [(-0.5, -0.5), (-0.5, 0.5), (0.5, -0.5), (0.5, 0.5)]:
            Q.append((X + dx * r, Y + dy * r, r / 2))

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

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

a.sort()

result = 0
mod = 10**9+7

def solve(x, y):
    if x == 0:
        return 1
    else:
        x = min(x, y-x)
        r = 1
        for i in range(y-x+1, y+1):
            r *= i
        for i in range(1, x+1):
            r //= i
        return r



for i in range(n-k+1):
    for j in range(i+k-1, n):
        result = (result+(a[j]-a[i])*solve(k-2, j-i-1))%mod
print(result)

### FIXED CODE ###

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

a.sort()

result = 0
mod = 10**9+7

 
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
n = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, n+1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


if k==1:
    print(0)
else:
    result = 0
    for i in range(N-k+1):
        result += (a[N-i-1]-a[i])*cmb(N-1-i, k-1)
        result %= mod

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

from collections import OrderedDict
n, q = [int(el) for el in input().split(' ')]
data = {}
for _ in range(q):
    a, v = [int(el) for el in input().split(' ')]
    if a in data:
        data[a] += v
    else:
        data[a] = v
    tmp = OrderedDict(sorted(data.items(), key=lambda t: t[0]))
    result = OrderedDict(sorted(tmp.items(), key=lambda t: t[1], reverse=True))
    print(*result.popitem(False))

### FIXED CODE ###

n, q = [int(el) for el in input().split(' ')]
data = [0] * n
result, index = 0, 1
for _ in range(q):
    a, v = [int(el) for el in input().split(' ')]
    data[a-1] += v
    if v > 0:
        if result < data[a-1]:
            result, index = data[a-1], a
        elif result == data[a-1]:
            index = min(index, a)
    else:
        if index == a:
            result = max(data)
            index = data.index(result) + 1
    print(index, result)
### BUGGY CODE ###

N = int(input())
I = [i for i in range(1,N+1)]
P = [i for i in range(1,N+1)]
P.remove(1)
P.append(1)

ans = 0

for i in range(len(I)):
    ans += I[i] % P[i]
print(ans)


### FIXED CODE ###

N = int(input())

print(N * (N - 1) // 2)
### BUGGY CODE ###

s = list(input())

dream = list("dream")
dreamer = list("dreamer")
erase = list("erase")
eraser = list("eraser")

s.reverse()
dream.reverse()
dreamer.reverse()
erase.reverse()
eraser.reverse()

while s != []:
    if s[0:7] == dreamer:
        del s[0:7]
    elif s[0:6] == eraser:
        del s[0:6]
    elif s[0:5] == dream:
        del s[0:5]
    elif s[0:5] == erase:
        del s[0:5]
    else:
        print("NO")
        exit()

print("YES")


### FIXED CODE ###

s = input()

dreamer = "dreamer"
eraser = "eraser"
dream = "dream"
erase = "erase"


while s != "":
    if s.endswith(dreamer):
        s = s[:-7]
    elif s.endswith(eraser):
        s = s[:-6]
    elif s.endswith(dream):
        s = s[:-5]
    elif s.endswith(erase):
        s = s[:-5]
    else:
        print("NO")
        exit()

print("YES")