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

from collections import Counter

N = int(input())
S = []
for i in range(N):
    S.append(Counter(list(str(input()))))

counter = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i]==S[j]:
            counter += 1
        else:
            continue

print(counter)

### FIXED CODE ###

from collections import Counter

N = int(input())
t = list(["".join(sorted(list(input()))) for i in range(N)])

counter = 0
for v in Counter(t).values():
    if v > 1:
        counter += (v*(v-1))//2

print(counter)
### BUGGY CODE ###

from collections import deque
import sys

readline = sys.stdin.readline

H, W = map(int, readline().split())
a = [readline() for _ in range(H)]


def adjacent_vertices(r, c):
    yield r - 1, c
    yield r + 1, c
    yield r, c - 1
    yield r, c + 1


def can_use(arg):
    r, c = arg
    return (0 <= r < H and 0 <= c < W) and (dist[r][c] == -1)


gen = ((r, c) for r in range(H) for c in range(W) if a[r][c] == '#')

# BFSで黒から最遠点までの距離を求める
dist = [[-1] * W for _ in range(H)]
q = deque()
for r, c in gen:
    dist[r][c] = 0
    q.append((r, c))
while q:
    r, c = q.popleft()
    d = dist[r][c]
    for nr, nc in filter(can_use, adjacent_vertices(r, c)):
        dist[nr][nc] = d + 1
        q.append((nr, nc))

print(d)


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
a = [input() for _ in range(H)]

dist = [[-1] * W for _ in range(H)]
dq = deque()

for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            dist[r][c] = 0
            dq.append((r, c))


def in_range(r, c):
    return 0 <= r < H and 0 <= c < W


dr_s = (0, 0, -1, 1)
dc_s = (-1, 1, 0, 0)

d = 0
while dq:
    r, c = dq.popleft()
    d = dist[r][c]
    for dr, dc in zip(dr_s, dc_s):
        nr = r + dr
        nc = c + dc
        if not in_range(nr, nc): continue
        if dist[nr][nc] != -1: continue
        dist[nr][nc] = d + 1
        dq.append((nr, nc))

print(d)
### BUGGY CODE ###

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

A_cumsum, B_cumsum = [0], [0]

for i in range(n):
    A_cumsum.append(A_cumsum[i] + A[i])
    
for j in range(m):
    B_cumsum.append(B_cumsum[j] + B[j])
    
ans = 0

for i, a in enumerate(A_cumsum):
    if a > k:
        break
    
    for j, b in enumerate(B_cumsum):
        if a + b > k:
            break
        elif (i + j) > ans:
                ans = (i + j)

print(ans)

### FIXED CODE ###

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

A_cumsum, B_cumsum = [0], [0]

for i in range(n):
    A_cumsum.append(A_cumsum[i] + A[i])
    
for j in range(m):
    B_cumsum.append(B_cumsum[j] + B[j])
    
ans, j = 0, m

for i in range(n + 1): # 0を最初に代入した分
    if A_cumsum[i] > k:
        break
    while A_cumsum[i] + B_cumsum[j] > k:
        j -= 1
    ans = max(ans, i + j)

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

def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())
def sieve(n):
  num = [True]*n
  num[0] = num[1] = False
  for i in range(2,int(n**0.5)+1):
    if num[i]:
      for j in range(i**2, n, i):
        num[j] = False
  return [i for i in range(2,n) if num[i]]

def main():
  q = int(input())
  for i in range(q):
    l, r = m()
    prime = sieve(r+1)
    cnt = 0
    for j in range(l, r+1):
      if j in prime:
        if (j+1) // 2 in prime:
          cnt += 1
    print(cnt)

if __name__ == '__main__':
  main()

### FIXED CODE ###

q = int(input())
l, r = [0]*q, [0]*q
for i in range(q):
    l[i], r[i] = map(int, input().split())

MAX = 101010
is_prime = [1]*MAX
is_prime[0] = 0
is_prime[1] = 0
for i in range(2,MAX):
    if not is_prime[i]: 
        continue
    for j in range(i*2, MAX, i):
        is_prime[j] = 0

a = [0]*MAX
for i in range(MAX):  # ,,2
    if i%2 == 0: 
        continue
    if is_prime[i] and is_prime[(i+1)//2]: 
        a[i] = 1

s = [0]*(MAX+1)
for i in range(MAX): 
    s[i+1] = s[i] + a[i]

for i in range(q):
    print(s[r[i]+1]-s[l[i]])
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(int(input()) for i in range(m))
x=[0]*(n+1)
x[0]=1
for i in range(1,n+1):
    x[i]=(x[i-1]+x[i-2])%(10**9+7)
    if i in a:
        x[i]=0
print(x[n])

### FIXED CODE ###

n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
 
x=[0]*(n+1)
x[0]=1
if 1 in A:
    x[1]=0
else:
    x[1]=1
 
for j in range(2,n+1):
    if j in A:
        x[j]=0
    else:
        x[j]=(x[j-1]+x[j-2])%(10**9+7)
        
 
print(x[n])
### BUGGY CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i, a in enumerate(A[:-1]):
    for b in A[i+1:]:
        ans = (ans + (a^b))%M

print(ans)

### FIXED CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

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

def main():
  inf = float("INF")
  a,b,q = map(int, input().split())
  s = [None] * (a + 3)
  s[0:2] = [-inf,-inf]
  s[-1] = inf
  t = [None] * (b + 3)
  t[0:2] = [-inf,-inf]
  t[-1] = inf
  for i in range(a):
      s[i+2] = int(input())
  for i in range(b):
      t[i+2] = int(input())

  from bisect import bisect_left

  dp0 = [None] * (a+3)
  dp1 = [None] * (b+3)

  def f(s,t,x,ss,i):
    if i == 0 and dp0[ss] != None: return abs(x - s[ss]) + dp0[ss]
    elif i == 1 and dp1[ss] != None: return abs(x - s[ss]) + dp1[ss]
    tr = bisect_left(t, s[ss])
    tl = tr - 1
    if i == 0: dp0[ss] = min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))
    if i == 1: dp1[ss] = min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))
    return abs(x - s[ss]) + min(abs(s[ss] - t[tl]), abs(s[ss] - t[tr]))


  for _ in range(q):
    ans = inf
    x = int(input())
    sr = bisect_left(s, x)
    ans = min(ans, f(s,t,x,sr,0))
    ans = min(ans, f(s,t,x,sr - 1,0))
    tr = bisect_left(t, x)
    ans = min(ans, f(t,s,x,tr,1))
    ans = min(ans, f(t,s,x,tr - 1,1))
    print(ans)
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

#A

"""
s = input().split("/")
if int(s[1]) <= 4:
    print("Heisei")
else:
    print("TBD")
"""
#B
"""
n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)
"""

#C
"""
n, a, b, c = map(int, input().split())
abc = [a,b,c]
x = [int(input()) for i in range(n)]
x.sort()
ans = []
flg = 0
for i in x:
    if i in abc:
        ans.append(i)
        flg = 1
if flg:
    for i in ans:
        abc.remove(i)
        x.remove(i)

"""
#D

a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
s.sort()
t.sort()

import bisect


for i in range(q):
    x = int(input())
    s_l = bisect.bisect_left(s, x) - 1
    t_l = bisect.bisect_left(t, x) - 1
    s_r = s_l + 1
    t_r = t_l + 1
    if s_l == -1:
        s_l = 0
    if t_l == -1:
        t_l = 0
    if s_l == a :
        s_l = a - 1
        s_r = a - 1
    if s_r == a:
        s_r = a - 1
    if t_l == b:
        t_l = b - 1
        t_r = b - 1
    if t_r == b:
        t_r = b - 1
    ans = min(abs(t[t_l] - s[s_r]) + min(abs(t[t_l] - x), abs(s[s_r] - x)),
    abs(s[s_l] - t[t_r]) + min(abs(s[s_l] - x), abs(t[t_r] - x)),
    abs(s[s_l] - t[t_l]) + min(abs(s[s_l] - x), abs(t[t_l] - x)),
    abs(s[s_r] - t[t_r]) + min(abs(s[s_r] - x), abs(t[t_r] - x)),
    )
    
    print(ans)
### BUGGY CODE ###

MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (1 << N)
dp[0] = 1
prev = [0]
for i, a in enumerate(A):
    temp = []
    for j in [k for k, v in enumerate(a) if v == 1]:
        bit = 1 << j
        for s in prev:
            dp[s] %= MOD
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                temp.append(new_s)
    prev = list(set(temp))
print(dp[(1 << N) - 1] % MOD)

### FIXED CODE ###

MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (1 << N)
dp[0] = 1
bits = [1 << i for i in range(N)]
cands = [[] for _ in range(N+1)]
for s in range(1 << N):
    temp = 0
    for n in range(N):
        if s & (1 << n): temp += 1
    cands[temp].append(s)
for i, a in enumerate(A):
    for j in [k for k, v in enumerate(a) if v == 1]:
        bit = bits[j]
        for s in cands[i]:
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                dp[new_s] %= MOD
print(dp[-1])
### BUGGY CODE ###

# ABC071-C　
N = int(input())
A_list = list(map(int, input().split()))

A_set = sorted(set(A_list), reverse = True)

side_list = [0, 0]

for i in range(len(A_set)):   # 大きい順に取っていき，リストで個数を確認する
    if len(side_list) >= 4:
        break
    count = A_list.count(A_set[i])    # リストの個数を確認
    if count == 2 or count == 3:
        side_list.append(A_set[i])
    if count >= 4:
        side_list.append(A_set[i])
        side_list.append(A_set[i])
        
side_list.sort(reverse = True)
print(side_list[0] * side_list[1])

### FIXED CODE ###

# ABC071-C
N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

for i in range(N-1):
    if A[i] == A[i+1]:
        A[i+1] = 0
    elif A[i] != A[i+1]:
        A[i] = 0
A.sort(reverse = True)
print(A[0] * A[1])
### BUGGY CODE ###

s=input()
n= len(s)
dp = [[0 for _ in range(13)]for _ in range(n)]

ss = s[0]
if ss == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    ss = int(ss)
    dp[0][ss] = 1

for i in range(1,n):
    ss = s[i]
    if ss == "?":
        for k in range(10):
            for j in range(13):
                t = (j * 10 +k) % 13
                dp[i][t] += dp[i-1][j]
    else:
        ss = int(ss)
        for j in range(13):
            t = (j * 10 +ss) % 13
            dp[i][t] += dp[i-1][j]

print(dp[n-1][5] % (10**9+7))

### FIXED CODE ###

def main():
    sts=input()
    n= len(sts)
    mod = 10**9+7
    s = []
    for c in sts:
        s.append(c)

    dp = [[0 for _ in range(13)]for _ in range(n)]

    ss = s[0]
    if ss == '?':
        for i in range(10):
            dp[0][i] = 1
    else:
        ss = int(ss)
        dp[0][ss] = 1

    for i in range(1,n):
        ss = s[i]
        if ss == "?":
            for k in range(10):
                for j in range(13):
                    dp[i][(j * 10 +k) % 13] += dp[i-1][j]
        else:
            for j in range(13):
                dp[i][(j * 10 +int(ss)) % 13] += dp[i-1][j]
        for j in range(13):
            dp[i][j]%= mod


    print(dp[n-1][5])

main()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
i = 0
SUM = 1
for i in range(N):
    SUM = SUM * A[i]
    i += 1

if SUM > 10**18:
    print(-1)
    
else:
    print(SUM)

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    SUM = 1

    if 0 in A:
        print(0)
        return

    for a in A:
        SUM = SUM * a
        if SUM > 1000000000000000000:
            print(-1)
            return

    print(SUM)
main()
### BUGGY CODE ###

N, M = (int(i) for i in input().split()) 

outs = [[] for i in range(N)]
ins = [0] * N

for _ in range(M):
    x, y = (int(i) for i in input().split())
    x -= 1
    y -= 1
    outs[x].append(y)
    ins[y] += 1

q = []
for i in range(N):
    if ins[i] == 0:
        q.append(i)

last = [0] * N
while q != []:
    qn = q.pop(0)
    for v in outs[qn]:
        ins[v] -= 1
        last[v] = max(last[v], last[qn] + 1)
        if ins[v] == 0:
            q.append(v)

print(max(last))

### FIXED CODE ###

N, M = (int(i) for i in input().split()) 

outs = [[] for i in range(N)]
ins = [0] * N

for _ in range(M):
    x, y = (int(i) for i in input().split())
    x -= 1
    y -= 1
    outs[x].append(y)
    ins[y] += 1

q = []
for i in range(N):
    if ins[i] == 0:
        q.append(i)

last = [0] * N
while q != []:
    qn = q.pop()
    for v in outs[qn]:
        ins[v] -= 1
        last[v] = max(last[v], last[qn] + 1)
        if ins[v] == 0:
            q.append(v)

print(max(last))
### BUGGY CODE ###

N,T = map(int,input().split())
data = [0] * N

M = 0
for i in range(N):
    data[i] = list(map(int,input().split()))
    M = max(M,data[i][0])

dp1 = [[0]*T for i in range(N)]

for j in range(T):
    if j < data[0][0]:
        dp1[0][j] = 0
    else:
        dp1[0][j] = data[0][1]

for j in range(T):
    for i in range(1,N):
        if data[i][0] <= j:
            dp1[i][j] = max(dp1[i-1][j],dp1[i-1][j-data[i][0]]+data[i][1])
        else:
            dp1[i][j] = dp1[i-1][j]

dp2 = [[0]*T for i in range(N)]

for j in range(T):
    if j < data[N-1][0]:
        dp2[N-i][j] = 0
    else:
        dp2[N-1][j] = data[N-1][1]

for j in range(T):
    for i in range(N-2,-1,-1):
        if data[i][0] <= j:
            dp2[i][j] = max(dp2[i+1][j],dp2[i+1][j-data[i][0]]+data[i][1])
        else:
            dp2[i][j] = dp2[i+1][j]

m = 0

for j in range(T):
    for i in range(N):
        if i == 0:
            m = max(m,dp2[i+1][T-1-j] + data[i][1])
        elif i == N-1:
            m = max(m,dp1[i-1][j] + data[i][1])
        else:
            m = max(m,dp1[i-1][j] + dp2[i+1][T-1-j] + data[i][1])

print(m)

### FIXED CODE ###

N,T = map(int,input().split())
data = [0] * N

M = 0
for i in range(N):
    data[i] = list(map(int,input().split()))
    M = max(M,data[i][0])

dp1 = [[0]*T for i in range(N)]

for j in range(T):
    if j < data[0][0]:
        dp1[0][j] = 0
    else:
        dp1[0][j] = data[0][1]

for j in range(T):
    for i in range(1,N):
        if data[i][0] <= j:
            dp1[i][j] = max(dp1[i-1][j],dp1[i-1][j-data[i][0]]+data[i][1])
        else:
            dp1[i][j] = dp1[i-1][j]

dp2 = [[0]*T for i in range(N)]

for j in range(T):
    if j < data[N-1][0]:
        dp2[N-i][j] = 0
    else:
        dp2[N-1][j] = data[N-1][1]

for j in range(T):
    for i in range(N-2,-1,-1):
        if data[i][0] <= j:
            dp2[i][j] = max(dp2[i+1][j],dp2[i+1][j-data[i][0]]+data[i][1])
        else:
            dp2[i][j] = dp2[i+1][j]

m = 0

for j in range(T):
    for i in range(N):
        if i == 0:
            m = max(m,dp2[i+1][T-1-j] + data[i][1])
        elif i == N-1:
            m = max(m,dp1[i-1][j] + data[i][1])
        else:
            m = max(m,dp1[i-1][j] + dp2[i+1][T-1-j] + data[i][1])

print(m)
### BUGGY CODE ###

import numpy as np
import sys

n,x,m = (int(i) for i in input().split())
l = np.array([x])
ans = x
for i in range(n-1):
    ans = ans**2%m
    if ans in l:
        loop_start = int(np.where(l==ans)[0])
        loop_num, mod = divmod((n-loop_start),(i-loop_start+1))
        print(np.sum(l[:loop_start]) + np.sum(l[loop_start:])*(loop_num)+np.sum(l[loop_start:loop_start+mod]))
        sys.exit()
    l = np.append(l,ans)
print(np.sum(l))

### FIXED CODE ###

import sys

n,x,m = (int(i) for i in input().split())
l = [x]
ans = x
memo_array = [-1]*(m+1)

for i in range(1,n):
    ans = ans**2%m
    idx = memo_array[ans]
    if idx != -1:
        loop_num, mod = divmod((n-idx),(i-idx))
        print(sum(l[:idx]) + sum(l[idx:])*(loop_num)+sum(l[idx:idx+mod]))
        sys.exit()
    l.append(ans)
    memo_array[ans]=i
print(sum(l))
### BUGGY CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

l,h=0,max(a)
while h-l>0.0000001:
    mid=(h+l)/2
    # print(l,h,mid)
    cnt=0
    for i in range(n):
        cnt+=math.ceil(a[i]/mid)-1
    #     print(a[i]/mid)
    # print(cnt)
    if cnt<=k:
        h=mid
    else:
        l=mid

# print(l)
print(math.ceil(l-0.000001))

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

l,h=0,max(a)
while h-l>1:
    mid=(h+l)//2
    # print(l,h,mid)
    cnt=0
    for i in range(n):
        cnt+=math.ceil(a[i]/mid)-1
    #     print(a[i]/mid)
    # print(cnt)
    if cnt<=k:
        h=mid
    else:
        l=mid

# print(l)
print(h)
### BUGGY CODE ###

input()
a=list(map(int,input().split()))
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][sum([j for j in a if j<=b[i]])<c[i]])for i in range(m)]

### FIXED CODE ###

import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
d=[0]*(n+1)
for i in range(1,n+1):d[i]=d[i-1]+a[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][d[bisect.bisect_right(a,b[i])]<c[i]]) for i in range(m)]
### BUGGY CODE ###

#coding:utf-8
def dbg(*something):
    if DEBUG:
        print(*something)






#正の宝石を戻すことはない
#負の宝石を戻すのは後半

from math import ceil,floor
DEBUG = False
N,K = list(map(int,input().split()))
V = list(map(int,input().split()))


#残りk回のとき深さk以下の場所に正の宝石がない→終了
#i回の操作で取れる石>それまでにとるi-1個の石の和
#深さiにある石vの価値：v - (それまでにとるi-1個の石の和　except (k-i)個の負の石)
'''
'''




def tansaku(left,right,rK,N,score):
    dbg(V[left:right+1],rK,N,score)


    max_v = score + sum(sorted(N)[rK:])


    # n = []
    for i in range(left,min(rK+left, ceil((right - left +1)/2)+left)):
        
        if V[i] <= 0:
            #n.append(V[i])
            continue

        #next_V = V[i+1:left+lenV]
        next_rK = rK - 1 - (i - left)
        next_tmp_v = tansaku(i+1,right,  next_rK, N+V[left:i], score+V[i])
        max_v = max(next_tmp_v , max_v)


        break

    # n = []
    for i in range(right ,max(right - ceil((right-left+1)/2)  ,right-rK)  ,-1 ):
        
        if V[i] <= 0:
            #n.append(V[i])
            continue

        #next_V = V[:i]
        next_rK = rK - 1 - (right - i)
        #next_tmp_v = tansaku(   left,   i- left -1  ,next_rK,N+n,score+V[i])
        next_tmp_v = tansaku(   left,   i-1  ,next_rK,N+V[i+1:right+1],score+V[i])
        max_v = max(next_tmp_v , max_v)
        break


    return max_v

print(tansaku(0,len(V)-1,K,[],0))






### FIXED CODE ###

#coding:utf-8



def main():
    
    def dbg(*something):
        if DEBUG:
            print(*something)


    #正の宝石を戻すことはない
    #負の宝石を戻すのは後半
    from sys import stdin
    from math import ceil,floor
    DEBUG = False
    N,K = list(map(int,stdin.readline().split()))
    V = list(map(int,stdin.readline().split()))
    
    max_value = 0
    dbg([i for i in range(3,-1,-1)])
    for getnum in range(1,min(N+1,K+1)):  #取る宝石の総数
        for a in range(getnum + 1):  #左から石を取る回数
            J = [0] * getnum #石
            b = getnum - a #右から石を取る回数
            for i in range(a):
                J[i] = V[i]
            for i in range(b):
                J[a+i] = V[-i-1]
            J.sort()
            #dbg(J,a,b)
            t = min(K-getnum,getnum) #捨てる石
           
            for i in range(t): 
                if J[i] >= 0:
                    t = i
                    break
            #dbg(J,i,t,a,b,J[t:])
            tmp_max = sum(J[t:])

            max_value = max(max_value,tmp_max)
    print(max_value)



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

N = int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
tmp = [abs(a[i-1]-a[i]) for i in range(1,len(a))]
tmp.append(abs(a[-1]-0))
a.append(0)
for i in range(1,len(a)-1):
    print(sum(tmp[:i-1])+abs(a[i-1]-a[i+1])+sum(tmp[i+1:]))


### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
a.insert(0,0),a.append(0)
k,sum = [],0
for i in range(1,len(a)):
    k.append(abs(a[i-1]-a[i]))
    sum += abs(a[i-1]-a[i])
#print(k,sum)
for i in range(1,N+1):
    if a[i-1]>=a[i]>=a[i+1] or a[i-1]<=a[i]<=a[i+1]:
        print(sum)
    else:
        print(sum-(k[i-1]+k[i])+abs(a[i-1]-a[i+1]))
### BUGGY CODE ###

import bisect

N = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

# BとCのセットだけ見てありえるパターンを出す
B_Cs = []
for b in Bs:
    index = bisect.bisect_left(Cs, b+1)
    B_Cs.append(N - index)

cnt = 0
for i, a in enumerate(As):
    index = bisect.bisect_left(Bs, a+1)
    cnt += sum(B_Cs[index:])
print(cnt)

### FIXED CODE ###

import bisect

N = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = 0
for b in Bs:
    a_b = bisect.bisect_left(As,b)
    b_c = N - bisect.bisect_right(Cs, b)
    
    cnt += a_b * b_c
print(cnt)
### BUGGY CODE ###

N,K = map(int,raw_input().split())
nums = list(map(int,raw_input().split()))
dp = [10000000000 for x in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(K):
        if i+j+1 < N:
            dp[i+j+1] = min(dp[i]+abs(nums[i]-nums[i+j+1]),dp[i+j+1])
print dp[N-1]

### FIXED CODE ###

import sys
raw_input = sys.stdin.readline
N,K = map(int,raw_input().split())
nums = list(map(int,raw_input().split()))
dp = [10000000000 for x in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(K):
        if i+j+1 < N:
            dp[i+j+1] = min(dp[i]+abs(nums[i]-nums[i+j+1]),dp[i+j+1])
print dp[N-1]
### BUGGY CODE ###

input()
(*a,) = map(int, input().split())
ma = max(a)

最小公倍数 = ma
while not all(最小公倍数 % i == 0 for i in set(a)):
    最小公倍数 += ma
ans = 最小公倍数 / sum(最小公倍数 // i for i in a)
print([ans, int(ans)][ans % 1 == 0])

### FIXED CODE ###

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

ただの倍数 = 1
for i in set(a):
    ただの倍数 *= i
ans = ただの倍数 / sum(ただの倍数 // i for i in a)
print([ans, int(ans)][ans % 1 == 0])
### BUGGY CODE ###

import numpy as np

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

dp = [float('inf')] * (2 ** N)
dp[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    key = np.sum([2**(x-1) for x in c])
    
    ndp = dp.copy()
    for j in range(2**N):
        if dp[j | key] > ndp[j] + a:
            dp[j | key] = ndp[j] + a
            
if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1])


### FIXED CODE ###

# https://atcoder.jp/contests/abc142/submissions/7753443
 
N,M = map(int,input().split())
 
lis = [float("inf")] * (2 ** N)
lis[0] = 0
 
for i in range(M):
 
    a,b = map(int,input().split())
 
    c = list(map(int,input().split()))
 
    num = 0
    for j in c:
        num += 2 ** (j-1)
 
    nlis = lis.copy()
    for j in range(2 ** N):
 
        if lis[j | num] > nlis[j] + a:
            lis[j | num] = nlis[j] + a     
 
#print (lis)
if lis[2 ** N -1] == float("inf"):
    print (-1)
 
else:
    print (lis[2 ** N - 1])
### BUGGY CODE ###

import numpy as np
def piyo():
    _ = int(input())
    b = np.array(list(int(i) for i in input().split()),dtype=int)
    fuga = []
    piyopiyo = []
    for hoge in range(10 ** 5):
        for hogehoge in b:
            piyopiyo.append((hoge+1)%hogehoge)
        fuga.append(np.sum(piyopiyo))
        piyopiyo.clear()
    print(max(fuga))
        
if __name__ == '__main__':
    piyo()

### FIXED CODE ###

import numpy as np
def piyo():
    a = int(input())
    b = np.array(list(int(i) for i in input().split()),dtype=int)
    print(np.sum(b)-a)

if __name__ == '__main__':
    piyo()