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

from scipy.misc import comb
#from scipy.special import comb
import itertools

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

combi = list(itertools.combinations(range(1,N+1), 2))
#print(combi)
dist = {}
for i in range(1, N):
    dist[i] = 0

c = [min([kyori[1] - kyori[0], int(abs((kyori[1] - Y))) + 1 + int(abs((X - kyori[0])))]) for kyori in combi]

for i in range(len(c)):
    dist[c[i]] += 1
    #print(c, kyori)
dist2 = sorted(dist.items())
#print(dist, dist2)
for i in range(0, N-1):
    print(dist2[i][1])


### FIXED CODE ###

import itertools

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

combi = list(itertools.combinations(range(1,N+1), 2))
dist = [[i+1, 0] for i in range(0, N-1)]

c = [min([kyori[1] - kyori[0], int(abs((kyori[1] - Y))) + 1 + int(abs((X - kyori[0])))]) for kyori in combi]

for i in range(len(c)):
    dist[c[i]-1][1] += 1
for i in range(0, N-1):
    print(dist[i][1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
n, q = list(map(int, input().split(' ')))
inf = [[] for _ in range(n)]
p_list = [0 for _ in range(n)]
     
for i in range(n-1):
    a, b = list(map(int, input().split(' ')))
    inf[a-1].append(b-1)
    inf[b-1].append(a-1)
     
for i in range(q):
    p, x = list(map(int, input().split(' ')))
    p_list[p-1] += x
     
def add_p(num):
    if len(inf[num]) == 0:
        return 0
    for k in inf[num]:
        inf[k] = [x for x in inf[k] if x != num]
        p_list[k] += p_list[num]
        add_p(k)
    return 0
     
add_p(0)
print(*p_list)

### FIXED CODE ###

def main():
    n, q = map(int, input().split(' '))
    import sys
    from collections import deque
    sys.setrecursionlimit(10**7)

    visit = [True for _ in range(n)]
    point = [0 for _ in range(n)]
    dic = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(int, input().split(' '))
        dic[a-1].append(b-1)
        dic[b-1].append(a-1)
    for _ in range(q):
        p, x = map(int, input().split(' '))
        point[p-1] += x
    next_visit = deque()
    next_visit.append(0)
    visit[0] = False
    counter = 1
    while counter < n:
        t = next_visit.pop()
        for s in dic[t]:
            if visit[s]:
                point[s] += point[t]
                visit[s] = False
                counter += 1
                next_visit.append(s)
    print(*point)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import defaultdict
h, w, d = map(int, input().split())
D = defaultdict(list)
for i in range(h):
    for j, x in enumerate(map(int, input().split())):
        D[x%d].append((x, i, j))
q = int(input())
for i in range(q):
    a, b = map(int, input().split())
    tmp = sorted([x for x in D[a%d] if b>= x[0] >= a])
    _, s, t = tmp[0]
    ans = 0
    for _,  u, v in tmp[1:]:
        ans += abs(u-s)+abs(v-t)
        s, t = u, v
    print(ans)


### FIXED CODE ###

import sys
input=sys.stdin.readline
h, w, d = map(int, input().split())
p = dict()

for i in range(h):
    for j, x in enumerate(map(int, input().split())):
        p[x] = (i, j)

dp = [0]*(h*w+1)
for i in range(h*w+1):
    if d < i:
        dp[i] = dp[i-d] + abs(p[i][0]-p[i-d][0])+abs(p[i][1]-p[i-d][1])

q = int(input())
for i in range(q):
    a, b = map(int, input().split())
    ans = dp[b]-dp[a]
    print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import numpy as np

n = int(input())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
for i in range(0, -n, -1):
  C = np.roll(A, i) ^ B
  if np.array_equiv(C, C[-1]):
    print(-i, C[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
C = [0]*(3*n)
for i in range(n):
  C[i] = B[i]^B[(i+1)%n]
  C[i+n] = A[i]^A[(i+1)%n]
  C[i+n+n] = C[i+n]

def z_algo(S):
    N = len(S)
    A = [0]*N
    A[0] = N
    i, j = 1, 0
    while i < N:
        while i+j < N and S[j] == S[i+j]:
            j += 1
        A[i] = j
        if not j:
            i += 1
            continue
        k = 1
        while i+k < N and k+A[k] < j:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A  

P = z_algo(C)
for i, p in enumerate(P[n:n+n]):
  if p >= n:
    x = A[i]^B[0]
    print(i, x)
### BUGGY CODE ###

import sys
from collections import deque
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
A = deque(A)
for i in range(n):
    tmp = A.popleft()
    print(max(A))
    A.append(tmp)

### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
tmp = sorted(A)
maxa = max(A)
for i in range(n):
    if A[i] == maxa:
        print(tmp[-2])
    else:
        print(maxa)
### BUGGY CODE ###

N = int(input())
a = [[int(_) for _ in input().split()] for _ in range(N)]
MOD = 10**9+7

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

for i in range(N):
    for s in range(1<<N):
        if dp[i][s] == 0:continue
        for j in range(N):
            jb = 1<<j
            if not (s&jb) and a[i][j]:
                dp[i+1][s|jb] += dp[i][s]
    
print(dp[N][(1<<N)-1]%MOD)


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = [list(map(int,input().split())) for _ in range(N)]
    MOD = 10**9+7
    
    dp = [1] + [0 for _ in range(1<<N)]

    for i in range(N):
        use = [0 for _ in range((1<<N)+1)]
        for s in range(1<<N):
            if dp[s] == 0:
                continue
            for j in range(N):
                jb = 1<<j
                if not (s&jb) and a[i][j]:
                    use[s^jb] += dp[s]
        dp = use
    
    print(dp[(1<<N)-1]%MOD)

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

import numpy as np
A, B, Q = list(map(int, input().split()))
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
s.append(-100000000000);s.append(100000000000)
t.append(-100000000000);t.append(100000000000)
s = sorted(s, reverse=False)
t = sorted(t, reverse=False)
sn = np.array(s)
tn = np.array(t)

for i in range(Q):
    xi = int(input())
    sr = sn[sn.searchsorted(xi)]
    sl = sn[sn.searchsorted(xi) - 1]
    tr = tn[tn.searchsorted(xi)]
    tl = tn[tn.searchsorted(xi) - 1]

    ans = min(max(sr, tr) - xi, xi - min(sl, tl),
              tr - sl + min(tr - xi, xi - sl), sr - tl + min(sr - xi, xi - tl))
    print(ans)


### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
s.append(-100000000000);s.append(100000000000)
t.append(-100000000000);t.append(100000000000)
s = sorted(s, reverse=False)
t = sorted(t, reverse=False)

for i in range(Q):
    xi = int(input())
    sr = s[bisect.bisect_left(s, xi)]
    sl = s[bisect.bisect_left(s, xi) - 1]
    tr = t[bisect.bisect_left(t, xi)]
    tl = t[bisect.bisect_left(t, xi) - 1]

    ans = min(max(sr, tr) - xi, xi - min(sl, tl),
              tr - sl + min(tr - xi, xi - sl), sr - tl + min(sr - xi, xi - tl))
    print(ans)
### BUGGY CODE ###

#! /usr/bin/env python3
import itertools
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def solve(N: int, C: int, D: "List[List[int]]", c: "List[List[int]]"):

    colormap = [[] for _ in range(3)]
    for i in range(1,N+1):
        for j in range(1,N+1):
            k = i+j
            k %= 3
            colormap[k].append(c[i-1][j-1])

    ans = INF
    for _colors in itertools.permutations(list(range(1,C+1)),3):
        colors = list(_colors)
        res = 0
        for mod,current_colors in enumerate(colormap):
            for current in current_colors:
                color = colors[mod]
                res += D[current-1][color-1]

        ans = min(res,ans)

    
    print(ans)

    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(C)] for _ in range(C)]  # type: "List[List[int]]"
    c = [[int(next(tokens)) for _ in range(N)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, C, D, c)



if __name__ == "__main__":
    main()


### FIXED CODE ###

import numpy as np
import itertools
import sys
sys.setrecursionlimit(10**9)


INF=10**18
def solve(N,C,D,colormap,new_colormap):
    ans = INF
    for j in range(len(new_colormap)):
        new_colors = new_colormap[j]
        res = 0
        for mod in range(3):
            for current_color in range(1,C+1):
                if current_color == 0: continue
                new_color = new_colors[mod]
                res += D[current_color-1][new_color-1] * colormap[mod][current_color]

        ans = min(res,ans)

    
    print(ans)

    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(C)] for _ in range(C)]  # type: "List[List[int]]"
    c = [[int(next(tokens)) for _ in range(N)] for _ in range(N)]  # type: "List[List[int]]"


    colormap = np.zeros((3,C+1),dtype=int)
    for i in range(1,N+1):
        for j in range(1,N+1):
            k = i+j
            k %= 3
            colormap[k][c[i-1][j-1]] += 1
            

    new_color_comb = list(itertools.permutations(list(range(1,C+1)),3))
    solve(N, C, np.array(D), colormap, np.array(new_color_comb))



def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')

    # basic types: https://numba.pydata.org/numba-doc/0.13/types.html
    cc.export('solve', '(i8,i8,i8[:,:],i8[:,:],i8[:,:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    # cc_export()
    try:
        from my_module import solve
    except:
        cc_export()
        exit()

    main()
### BUGGY CODE ###

import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    k = int(input())
    S = input()
    n = len(S)
    dp = {0 : 1}
    for _ in range(n + k):
        ndp = defaultdict(int)
        for key, val in dp.items():
            if key == n:
                ndp[key] += 26 * val
                ndp[key] %= MOD
            else:
                ndp[key + 1] += val
                ndp[key + 1] %= MOD
                ndp[key] += 25 * val
                ndp[key] %= MOD

        dp = ndp
    print(dp[n])
resolve()

### FIXED CODE ###

import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def inv(self, n):
        return self._fact[n - 1] * self._invfact[n] % MOD

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD

    def perm(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[n - k] % MOD

def resolve():
    k = int(input())
    n = len(input())
    mf = modfact(n + k)
    ans = 0
    for i in range(n, n + k + 1):
        ans += mf.comb(n + k, i) * pow(25, n + k - i, MOD)
        ans %= MOD
    print(ans)
resolve()
### BUGGY CODE ###

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

U=10**6
mod=10**9+7

fact=[1]*(U+1)
fact_inv=[1]*(U+1)

for i in range(1,U+1):
    fact[i]=(fact[i-1]*i)%mod
fact_inv[U]=pow(fact[U],mod-2,mod)

for i in range(U,0,-1):
	fact_inv[i-1]=(fact_inv[i]*i)%mod

def comb(n,k):
    if k<0 or k>n:
        return 0
    x=fact[n]
    x*=fact_inv[k]
    x%=mod
    x*=fact_inv[n-k]
    x%=mod
    return x
def div(a,b):
    return (a*pow(b,mod-2,mod))%mod

def p(n,k):
    return div(fact[n],fact[n-k])
ans=0
for i in range(n+1):
    t=(comb(n,i)*p(m-i,n-i))%mod
    if i%2:ans=(ans-t)%mod
    else:ans=(ans+t)%mod
ans=(ans*p(m,n))%mod
print(ans)

### FIXED CODE ###

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

U=10**6
mod=10**9+7

fact=[1]*(U+1)
fact_inv=[1]*(U+1)

for i in range(1,U+1):
    fact[i]=(fact[i-1]*i)%mod
fact_inv[U]=pow(fact[U],mod-2,mod)

for i in range(U,0,-1):
	fact_inv[i-1]=(fact_inv[i]*i)%mod

def comb(n,k):
    if k<0 or k>n:
        return 0
    x=fact[n]
    x*=fact_inv[k]
    x%=mod
    x*=fact_inv[n-k]
    x%=mod
    return x
def div(a,b):
    return (a*pow(b,mod-2,mod))%mod

def p(n,k):
    return div(fact[n],fact[n-k])
ans=0
for i in range(n+1):
    t=(comb(n,i)*p(m-i,n-i))%mod
    if i%2:ans=(ans-t)%mod
    else:ans=(ans+t)%mod
ans=(ans*p(m,n))%mod
print(ans)
### BUGGY CODE ###

input();a,s=list(map(int,input().split())),0
for i in set(a):
  b=a.count(i)
  if (i-b)>(b-i):s+=b
  else:s+=abs(i-b)
print(s)

### FIXED CODE ###

from collections import Counter
input();a=Counter(list(map(int,input().split())))
print(sum([v if k>v else v-k for k,v in a.items()]))
### BUGGY CODE ###

s=input()
t=input()
n1,n2=len(s),len(t)
dp=[[0]*(n1+1) for i in range(n2+1)]
st=''
for i in range(1,n2+1):
    for j in range(1,n1+1):
        if s[j-1]==t[i-1]:
            dp[i][j]=dp[i-1][j-1]+1
            #st+=s[j-1]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
while i>0 and j>0:
    if t[i-1]==s[j-1]:
        st=s[j-1]+st
        i-=1
        j-=1
    elif dp[i][j-1]>dp[i-1][j]:
        j-=1
    else:
        i-=1
print(st)

### FIXED CODE ###

s=input()
t=input()
n1,n2=len(s),len(t)
dp=[[0]*(n1+1) for i in range(n2+1)]
st=''
for i in range(1,n2+1):
    for j in range(1,n1+1):
        if s[j-1]==t[i-1]:
            dp[i][j]=dp[i-1][j-1]+1
            #st+=s[j-1]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
while i>0 and j>0:
    if t[i-1]==s[j-1]:
        st=s[j-1]+st
        i-=1
        j-=1
    elif dp[i][j-1]>dp[i-1][j]:
        j-=1
    else:
        i-=1
print(st)
### BUGGY CODE ###

S = input()
Q = int(input())
TFC = [input().split() for _ in range(Q)]
for tfc in TFC:
    if tfc[0] == '1':
        S = S[::-1]
    else:
        if tfc[1] == '1':
            S = tfc[2]+S
        else:
            S = S+tfc[2]
print(S)

### FIXED CODE ###

S = input()
Q = int(input())
TFC = [input().split() for _ in range(Q)]
is_reversed = False
head = ''
tail = ''
for tfc in TFC:
    if tfc[0] == '1':
        is_reversed = not is_reversed
    else:
        if tfc[1] == '1':
            if is_reversed:
                tail += tfc[2]
            else:
                head += tfc[2]
        else:
            if is_reversed:
                head += tfc[2]
            else:
                tail += tfc[2]
if is_reversed:
    print(tail[::-1]+S[::-1]+head)
else:
    print(head[::-1]+S+tail)
### BUGGY CODE ###

from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for k in range(30, -1, -1):
    cnt = 0
    T = 1 << (k + 1)
    for i in range(N):
        A[i] %= T
        B[i] %= T

    B = sorted(B)

    for i in range(N):
        T = 1 << k
        cnt += bisect_left(B, 2 * T - A[i]) - bisect_left(B, T - A[i])
        cnt += bisect_left(B, 4 * T - A[i]) - bisect_left(B, 3 * T - A[i])

    if cnt % 2 == 1:
        ans |= 1 << k


print(ans)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
T = 1 << 30
for k in range(30, -1, -1):
    cnt = 0

    TT = T << 1
    for i in range(N):
        A[i] %= TT
        B[i] %= TT

    A = sorted(A)
    B = sorted(B)

    d0 = bisect_left(B, T - A[0])
    d1 = bisect_left(B, 2 * T - A[0])
    d2 = bisect_left(B, 3 * T - A[0])
    for i in range(N):
        while d0 - 1 >= 0 and B[d0 - 1] >= T - A[i]:
            d0 -= 1
        while d1 - 1 >= 0 and B[d1 - 1] >= 2 * T - A[i]:
            d1 -= 1
        while d2 - 1 >= 0 and B[d2 - 1] >= 3 * T - A[i]:
            d2 -= 1

        cnt += d1 - d0
        cnt += N - d2

    if cnt % 2 == 1:
        ans |= T

    T = T >> 1

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

def main():
  s = input()
  mod = 10**9+7
  dp = [0]*13
  dp[0] = 1
  digit = 1
  for i in range(len(s)-1, -1, -1):
    nextDP = [0]*13
    if s[i] == "?":
      for k in range(10):
        for j in range(13):
          t = (digit * k + j)%13
          nextDP[t] = (dp[j] + nextDP[t]) % mod
    else:
      si = int(s[i])
      for j in range(13):
        t = (digit * si + j)%13
        nextDP[t] = (dp[j] + nextDP[t]) % mod
    dp = nextDP
    digit *= 10
  print(dp[5])

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  s = input()
  mod = 10**9+7
  dp = [0]*13
  dp[0] = 1
  digit = 1
  for i in range(len(s)):
    nextDP = [0]*13
    if s[i] == "?":
      for k in range(10):
        for j in range(13):
          t = (k + j * 10)%13
          nextDP[t] = (dp[j] + nextDP[t]) % mod
    else:
      si = int(s[i])
      for j in range(13):
        t = (si + j * 10)%13
        nextDP[t] = (dp[j] + nextDP[t]) % mod
    dp = nextDP
    digit *= 10
  print(dp[5])

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

#!/usr/bin/env python3
#ABC111 C

from operator import itemgetter
n = int(input())
v = list(map(int,input().split()))

s = []
t = []
for i in range(n):
    if i % 2 == 0:
        s.append(v[i])
    else:
        t.append(v[i])

ss = list(set(s))
tt = list(set(t))

sc = []
tc = []
for i in range(len(ss)):
    sc.append([ss[i],s.count(ss[i])])
for i in range(len(tt)):
    tc.append([tt[i],t.count(tt[i])])
sc.sort(key = itemgetter(1))
tc.sort(key = itemgetter(1))
if sc[-1][0] == tc[-1][0]:
    if len(sc) == 1 and len(tc) == 1:
        print(n - sc[-1][1])
    elif len(sc) == 1 and len(tc) != 1:
        print(n - sc[-1][1] - tc[-2][1])
    elif len(sc) != 1 and len(tc) == 1:
        print(n - sc[-2][1] - tc[-1][1])
    else:
        ma = max(sc[-2][1],tc[-2][1])
        print(n - sc[-1][1] - ma)
else:
    print(n - sc[-1][1] - tc[-1][1])


### FIXED CODE ###

#!/usr/bin/env python3
#ABC111 C

from operator import itemgetter
import collections

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

s = [v[i] for i in range(n) if i % 2 == 0]
t = [v[i] for i in range(n) if i % 2 == 1]

sc = collections.Counter(s)
tc = collections.Counter(t)
sc = list(sc.items())
tc = list(tc.items())
ls = len(sc)
lt = len(tc)
sc.sort(key = itemgetter(1))
tc.sort(key = itemgetter(1))
if sc[-1][0] == tc[-1][0]:
    if ls == 1 and lt == 1:
        print(n - sc[-1][1])
    elif ls == 1 and lt != 1:
        print(n - sc[-1][1] - tc[-2][1])
    elif ls != 1 and lt == 1:
        print(n - sc[-2][1] - tc[-1][1])
    else:
        ma = max(sc[-2][1],tc[-2][1])
        print(n - sc[-1][1] - ma)
else:
    print(n - sc[-1][1] - tc[-1][1])
### BUGGY CODE ###

#coding utf-8
N=int(input())

roma = [0 for i in range(N)]

for i in range(N):
  tmp=list(input().strip())
  tmp.sort()
  roma[i]=''.join(tmp)

ans=0    
for i in range(N):
  ans +=roma[i+1:].count(roma[i])
    
print(ans)

### FIXED CODE ###

#coding utf-8
N=int(input())

dict={}

ans=0    
for i in range(N):
  tmp = "".join(sorted(input()))
  if tmp not in dict:
    dict[tmp]=0
  else:
    dict[tmp]+=1
    ans+=dict[tmp]
    
print(ans)
### BUGGY CODE ###

import sys
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        for w in range(1,3501):
            if N==int((4*h*n*w)/((h*n+n*w+w*h))):
                print(h,n,w)
                sys.exit()

### FIXED CODE ###

import sys
N=int(input())
for h in range(1,3501):
    for n in range(h,3501):
        if 4*n*h-N*h-N*n >0:
            if (N*h*n)%(4*n*h-N*h-N*n)==0:
                w=int((N*h*n)/(4*n*h-N*h-N*n))
                print(h,n,w)
                sys.exit()
### BUGGY CODE ###

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

for i in range(1,n+1):
    print(a.count(i))

### FIXED CODE ###

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

b=[0]*n
for i in a:
    b[i-1]+=1

for i in b:
    print(i)
### BUGGY CODE ###

h, w = map(int, input().split())
data = [list(input()) for _ in range(h)]

cnt_l, cnt_r, cnt_u, cnt_d = [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if data[i][j] == "#":
            cnt_l[i][j] = 0
        else:
            cnt_l[i][j] = cnt_l[i][j - 1] + 1
    
        if data[i][w - j - 1] == "#":
            cnt_r[i][w - j - 1] = 0
        else:
            if j == 0:
                cnt_r[i][w - j - 1] = 1
            else:
                cnt_r[i][w - j - 1] = cnt_r[i][w - j] + 1

for j in range(w):
    for i in range(h):
        if data[i][j] == "#":
            cnt_u[i][j] = 0
        else:
            cnt_u[i][j] = cnt_u[i - 1][j] + 1

        if data[h - i - 1][j] == "#":
            cnt_d[h - i - 1][j] = 0
        else:
            if i == 0:
                cnt_d[h - i - 1][j] = 1
            else:
                cnt_d[h - i - 1][j] = cnt_d[h - i][j] + 1

ans = 0
for i in range(h):
    for j in range(w):
        total= cnt_l[i][j] + cnt_r[i][j] + cnt_u[i][j] + cnt_d[i][j] - 3
        ans = max(ans, total)
print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
data = [list(input()) for _ in range(h)]

cnt_l, cnt_r, cnt_u, cnt_d = [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if data[i][j] == "#":
            cnt_l[i][j] = 0
        else:
            cnt_l[i][j] = cnt_l[i][j - 1] + 1
    
        if data[i][w - j - 1] == "#":
            cnt_r[i][w - j - 1] = 0
        else:
            if j == 0:
                cnt_r[i][w - j - 1] = 1
            else:
                cnt_r[i][w - j - 1] = cnt_r[i][w - j] + 1

for j in range(w):
    for i in range(h):
        if data[i][j] == "#":
            cnt_u[i][j] = 0
        else:
            cnt_u[i][j] = cnt_u[i - 1][j] + 1

        if data[h - i - 1][j] == "#":
            cnt_d[h - i - 1][j] = 0
        else:
            if i == 0:
                cnt_d[h - i - 1][j] = 1
            else:
                cnt_d[h - i - 1][j] = cnt_d[h - i][j] + 1

ans = 0
for i in range(h):
    for j in range(w):
        total= cnt_l[i][j] + cnt_r[i][j] + cnt_u[i][j] + cnt_d[i][j] - 3
        ans = max(ans, total)

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

from fractions import gcd

MOD = 10 ** 9 + 7

N = int(input())

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

B = [1] * (N + 1)

for index, a in enumerate(A):
    tmp = gcd(B[index], a)
    B[index + 1] = B[index] * a // tmp

C = [1] * (N + 1)
for i in range(N - 1, -1, -1):
    tmp =gcd(C[i + 1], A[i])
    C[i] = C[i + 1] * A[i] // tmp

# print (B)
# print (C)

ans = 0
for i in range(N):
    tmp1 = gcd(B[i], C[i + 1])
    tmp2 = B[i] * C[i + 1] // tmp1

    tmp3 = gcd(tmp2, A[i])
    tmp4 = tmp2 * A[i] // tmp3

    ans += (tmp4 // A[i] % MOD)
    ans %= MOD

    # print (ans)

print (ans)

### FIXED CODE ###

def main():
    from fractions import gcd

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

    MOD = 10 ** 9 + 7

    tmp = 1
    for a in A:
        tmp *= a // gcd(tmp, a)

    ans = 0
    for a in A:
        ans += tmp // a
    ans %= MOD

    print (ans)

if __name__ == '__main__':
    main()