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

def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = []
    tmp = (0,)*(N+1)
    A.append(tmp)
    for i in range(N):
        tmp = (0,) + tuple(map(int, input().split()))
        A.append(tmp)
    ans = 0
    B = [1]*(N+1)
    C = [[0]*N for i in range(N+1)]
    count = 0
    flag = 0
    while count < N*(N-1)//2 and  flag == 0:
        flag = 1
        for i in range(1,N+1):
            if B[i] < N:
                j = A[i][B[i]]
                if A[j][B[j]] == i:
                    k = max(C[i][B[i]-1], C[j][B[j]-1]) + 1
                    C[i][B[i]] = k
                    C[j][B[j]] = k
                    B[i] +=  1
                    B[j] += 1
                    count += 1
                    flag = 0
                    break
    #print(C)
    ans = 0
    for i in C:
        if i[-1] > ans:
            ans = i[-1]
    if ans == 0:
        print(-1)
    else:
        print(ans)
    
    
    
main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = []
    tmp = (0,)*(N+1)
    A.append(tmp)
    for i in range(N):
        tmp = (0,) + tuple(map(int, input().split()))
        A.append(tmp)
    B = [1]*(N+1)
    C = [[0]*N for i in range(N+1)]
    count = 0
    flag = 0
    
    #1試合目
    Q = []
    nextQ = []
    for i in range(1,N+1):
        j = A[i][B[i]]
        if A[j][B[j]] == i:
            ii = min(i,j)
            jj = max(i,j)
            if not (ii,jj) in nextQ:
                nextQ.append((ii,jj))
    
    day = 0    
    while count < N*(N-1)//2 and len(nextQ) >= 1:
        day += 1
        Q = nextQ
        nextQ = []
        for T in Q:
            i = T[0]
            j = T[1]
            k = max(C[i][B[i]-1], C[j][B[j]-1]) + 1
            C[i][B[i]] = k
            C[j][B[j]] = k
            B[i] += 1
            B[j] += 1
            count += 1
            if B[i] < N:
                I = A[i][B[i]]
                if A[I][B[I]] == i:
                    ii = min(i,I)
                    jj = max(i,I)
                    if not (ii,jj) in nextQ:
                        nextQ.append((ii,jj))
            if B[j] < N:
                J = A[j][B[j]]
                if A[J][B[J]] == j:
                    ii = min(j,J)
                    jj = max(j,J)
                    if not (ii,jj) in nextQ:
                        nextQ.append((ii,jj))
            
                    
    #print(C)
    if count < N*(N-1)//2:
        print(-1)
    else:
        print(day)
    
    
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    # print(ans)
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        # print(ans)
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)
### BUGGY CODE ###

s = input()
t = input()
n,m = map(len,[s,t])

dp = [['' for i in range(m+1)] for j in range(n+1)]

for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1] = dp[i][j] + s[i]
        else:
            dp[i+1][j+1] = dp[i][j]
        dp[i+1][j+1] = dp[i+1][j] if len(dp[i+1][j])>len(dp[i+1][j+1]) else dp[i+1][j+1]
        dp[i+1][j+1] = dp[i][j+1] if len(dp[i][j+1])>len(dp[i+1][j+1]) else dp[i+1][j+1]
print(dp[n][m])

### FIXED CODE ###

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

S = list(ST())
T = list(ST())
dp = FILL2(0,len(S)+1,len(T)+1)
for i in range(len(S)+1):
    for j in range(len(T)+1):
        if i+1<=len(S) and j+1<=len(T):
            if S[i]==T[j]:
                dp[i+1][j+1] = dp[i][j] + 1
        if i+1<=len(S):
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= len(T):
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])

l = dp[len(S)][len(T)]
i = len(S)
j = len(T)
ans = ''
while l > 0:
    if S[i-1]==T[j-1]:
        i -= 1
        j -= 1
        l -= 1
        ans = S[i]+ans
    else:
        if dp[i][j-1]==dp[i][j]:
            j -= 1
        else:
            i -= 1
print(ans)
### BUGGY CODE ###

def c_candles(N, K, X):
    from bisect import bisect_left
    negative_pos = X[:bisect_left(X, 0)][::-1]
    positive_pos = X[bisect_left(X, 0):]
    negative_pos_rel = negative_pos[:]
    positive_pos_rel = positive_pos[:]
    for k in range(1, len(negative_pos)):
        negative_pos_rel[k] -= negative_pos[k - 1]
    for k in range(1, len(positive_pos)):
        positive_pos_rel[k] -= positive_pos[k - 1]
    # print(X, negative_pos_rel, positive_pos_rel)

    ans = float('inf')
    for k in range(len(negative_pos) + 1):
        length = 0
        n = K - k
        if n > len(positive_pos):
            continue

        length += abs(sum(negative_pos_rel[:k]))
        length += length
        length += sum(positive_pos_rel[:n])
        ans = min(ans, length)
    #     print(n, k, length)
    # print('-')
    for n in range(len(positive_pos) + 1):
        length = 0
        k = K - n
        if k > len(negative_pos):
            continue
        length += sum(positive_pos_rel[:n])
        length += length
        length += abs(sum(negative_pos_rel[:k]))
        ans = min(ans, length)
        # print(n, k, length)

    return ans

N, K = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
print(c_candles(N, K, X))

### FIXED CODE ###

def c_candles(N, K, X):
    ans = float('inf')
    # [left, right] が指す連続したK本のろうそくに火をつけるといい
    for left in range(N):
        right = left + K - 1
        if right >= N:  # 右端がろうそくを指していない
            break
        # left→rightへ付けていく場合とright→leftへ付けていく場合
        ans = min(ans, abs(X[left]) + abs(X[right] - X[left]))
        ans = min(ans, abs(X[right]) + abs(X[right] - X[left]))
    return ans

N, K = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
print(c_candles(N, K, X))
### BUGGY CODE ###


def main():
    N = int(input())
    dict = {}

    for _ in range(N):
        word = input()
        if word in dict:
            dict[word] += 1
        else:
            dict[word] = 0

    max_k_list = [kv[0] for kv in dict.items() if kv[1] == max(dict.values())]
    max_k_list = sorted(max_k_list)
    for m in max_k_list:
        print(m)
    return 0


if __name__ == '__main__':
    main()

### FIXED CODE ###


def main():
    N = int(input())
    dict = {}

    for _ in range(N):
        word = input()
        if word in dict:
            dict[word] += 1
        else:
            dict[word] = 0

    m = max(dict.values())
    dict = sorted(dict.items(), key=lambda x: x[0])

    for d in dict:
        if d[1] == m:
            print(d[0])
    return 0


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

N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
A_replace = A
for i in range(Q):
  b,c = (int(x) for x in input().split())
#  print(b,c,A)
  A_replace = [c if i == b else i for i in A_replace]
#  print(A_replace)
  print(sum(A_replace))

### FIXED CODE ###

from collections import Counter
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
suma = sum(A)
counter = Counter(A)
for i in range(Q):
  b,c = (int(x) for x in input().split())
  suma = counter[b]*(c-b) + suma
  print(suma)
  if b in counter:
    if c in counter:
      counter[c] += counter[b]
      counter[b] = 0
    else:
      counter[c] = counter[b]
      counter[b] = 0
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a=[]
for i in range(0,n):
  a.append(int(input()))
a.sort()

b = [a[0]]
#a=a[1:]
li=1
ri=len(a)-1

while ri>=li:
  ln = abs(b[0]-a[li])
  lx = abs(b[0]-a[ri])
  rn = abs(b[len(b)-1]-a[li])
  rx = abs(b[len(b)-1]-a[ri])

  x = max(ln, max(lx, max(rn, rx)))
  
  if x == ln:
    b.insert(0,a[li])
    li=li+1
  elif x == lx:
    b.insert(0,a[ri])
    ri=ri-1
  elif x == rn:
    b.append(a[li])
    li=li+1
  else:
    b.append(a[ri])
    ri=ri-1

res=0
for i in range(0,len(b)-1):
  res=res+abs(b[i]-b[i+1])
print(res)


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a=[]
for i in range(0,n):
  a.append(int(input()))
a.sort()

l = a[0]
r = a[0]

li=1
ri=len(a)-1

res = 0

while ri>=li:
  ln = abs(l-a[li])
  lx = abs(l-a[ri])
  rn = abs(r-a[li])
  rx = abs(r-a[ri])

  x = max(ln, max(lx, max(rn, rx)))
  
  if x == ln:
    res = res + ln
    l=a[li]
    li=li+1
  elif x == lx:
    res = res + lx
    l=a[ri]
    ri=ri-1
  elif x == rn:
    res = res + rn
    r=a[li]
    li=li+1
  else:
    res = res + rx
    r=a[ri]
    ri=ri-1

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

mod = 10 ** 9 + 7

N, *A = map(int, open(0).read().split())

C = [0] * (max(A) + 1)
for a in A:
    i = 2
    while i * i <= a:
        if a % i == 0:
            cnt = 0
            while a % i == 0:
                a //= i
                cnt += 1
            C[i] = max(C[i], cnt)
        i += 1
    if a > 1:
        C[a] = max(C[a], 1)

L = 1
for i, c in enumerate(C):
    L *= pow(i, c)
    L %= mod

print(L * sum(pow(a, mod - 2, mod) for a in A) % mod)

### FIXED CODE ###

from fractions import gcd
from functools import reduce

def main():
    lcm = lambda a, b: a * b // gcd(a, b)
    mod = 10 ** 9 + 7

    N, *A = map(int, open(0).read().split())

    L = reduce(lcm, A)
    print(sum(L // a for a in A) % mod)

main()
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def group_count(self):
        temp = []
        temp.clear()
        temp = [(-self.parents[i])*(-self.parents[i]-1)//2 for i in range(len(self.parents)) if self.parents[i] < -1]
        return sum(temp)
N,M = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
uf = UnionFind(N)
init = N*(N-1)//2
ans = []
temp = []
for i in range(1, M+1):
    uf.union((AB[-i][0]-1), (AB[-i][1]-1))
    ans.append(init-uf.group_count())
for i in range(1, M):
    print(ans[-i-1])
print(init)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        a = self.parents[x]
        b = self.parents[y]
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return(a*b)
N,M = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
uf = UnionFind(N)
init = N*(N-1)//2
ans = []
temp = init
for i in range(1, M+1):
    temp -= uf.union((AB[-i][0]-1), (AB[-i][1]-1))
    ans.append(temp)
for i in range(1, M):
    print(ans[-i-1])
print(init)
### BUGGY CODE ###

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

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

cnt = 0
import itertools
for l,r in itertools.product(range(1,n+1),range(1,n+1)):
    if l >= r:
        if l == r:
            if a[l-1] == 0:
                cnt += 1
        continue
    if s[r] - s[l-1] == 0:
        cnt += 1

print(cnt)

### FIXED CODE ###

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

b = [0] + a
s = list(itertools.accumulate(b))


c = collections.Counter(s)
cm = c.most_common()
cnt = 0
for v in cm:
    if v[1] > 1:
        cnt += (v[1]*(v[1]-1) // 2)
print(cnt)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

s=[]
for _ in range(h):
    s.append(list(input()))

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
    
    if s[y][x]=='#':
        return
    
    s[y][x]='#'
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i:
                continue
            if x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]!='#':
                nxt.append([y+i,x+j,now+1])
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        rcl(y+yy,x+xx,now)


while nxt:
    i=nxt.pop(0)
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

s=[]
for _ in range(h):
    s.append(list(input()))

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
    
    if s[y][x]=='#':
        return
    
    s[y][x]='#'
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        
        rcl(y+yy,x+xx,now)
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i or x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]=='.':
                nxt.append([y+i,x+j,now+1])
                s[y+i][x+j]=now+1


while nxt:
    i=nxt.pop(0)
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)
### BUGGY CODE ###

def bi(x):
    x = int(x)
    i = 0
    o = [0]*61
    while x > 0:
        o[i] = x % 2
        x //= 2
        i += 1
    return o

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

# print(*A,sep='\n')
a = 0
ruijoo = 1
bbb = 0
for h in range(61):
    B = list(map(lambda x: x[h],A))
    isZero = sum(map(lambda x: x == 0,B))
    isOne = sum(map(lambda x: x == 1,B))
    bbb += sum(map(lambda x:isZero if x else isOne,B))*ruijoo
    ruijoo *= 2
    ruijoo %= 1000000007

bbb *= 500000004
bbb %= 1000000007
print(bbb)

### FIXED CODE ###

def bi(x):
    x = int(x)
    i = 0
    o = [0]*61
    while x > 0:
        o[i] = x % 2
        x //= 2
        i += 1
    return o

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

# print(*A,sep='\n')
a = 0
ruijoo = 1
bbb = 0
B = [0]*N
h = 0
while h < 61:
    i = 0
    isOne = 0
    while i < N:
        aaaa = A[i][h]
        isOne += aaaa
        B[i] = aaaa
        i += 1
    isZero = N - isOne
    C = [isOne,isZero]
    bbbb = 0
    i = 0
    while i < N:
        bbbb += C[B[i]]
        i += 1
    bbbb *= ruijoo
    bbb += bbbb
    bbb %= 1000000007
    ruijoo *= 2
    ruijoo %= 1000000007
    h += 1

bbb *= 500000004
bbb %= 1000000007
print(bbb)
### BUGGY CODE ###

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

### FIXED CODE ###

def fibonacci(n):
	if n==0:
		return 0
	a,b=1,1
	for i in range(0,int((n-1)/2)):
		a+=b
		b+=a
	if n%2!=0:
		return a
	return b

n=[int(i) for i in input().split()]
f=1
a=-1
for i in range(0,n[1]):
	b=int(input())
	f*=fibonacci(b-a-1)
	a=b
f*=fibonacci(n[0]-a)
print(f%1000000007)
### BUGGY CODE ###

s = input()
q = int(input())
isReverse = -1
for i in range(q):
    query = input().split()
    if(query[0] == "1"):
        isReverse *= -1
    else:
        if(query[1] == "1"):
            if(isReverse == 1):
                s = "".join([s, query[2]])
            else:
                s = "".join([query[2], s])
        else:
            if(isReverse == 1):
                s = "".join([query[2], s])
            else:
                s = "".join([s, query[2]])
if(isReverse == -1):
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

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

ans = [" " for n in range(2*q + 1)]
ans[q] = s
frontIndex = q - 1
endIndex = q + 1
isReverse = -1

for i in range(q):
    query = input().split()
    if(query[0] == "1"):
        isReverse *= -1
    else:
        if(query[1] == "1"):
            if(isReverse == 1):
                ans[endIndex] = query[2]  
                endIndex += 1
            else:
                ans[frontIndex] = query[2]
                frontIndex -= 1
        else:
            if(isReverse == 1):
                ans[frontIndex] = query[2] 
                frontIndex -= 1
            else:
                ans[endIndex] = query[2]
                endIndex += 1
ans = "".join(ans).strip()
if(isReverse == -1):
    print(ans)
else:
    print(ans[::-1])
### BUGGY CODE ###

#入力
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[]
for i in range(h):
  s_=list(input())
  s.append(s_)
#幅優先探索
from collections import deque
q=deque([(ch-1,cw-1)])
used=[[float("INF")]*w for i in range(h)]
used[ch-1][cw-1]=0
while len(q)>0:
  y,x=q.popleft()
  X=((-1,0),(1,0),(0,1),(0,-1))
  for dy,dx in X:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]
        q.appendleft((ny,nx))
  Y=(-2,-1,0,1,2)
  for dx in Y:
    for dy in Y:
      if not(dx==0 and dy==0):
        if (dy,dx) not in X:
          nx=x+dx
          ny=y+dy
          if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
            if used[ny][nx]>used[y][x]:
              used[ny][nx]=used[y][x]+1
              q.append((ny,nx))

if used[dh-1][dw-1]==float("INF"):
  print(-1)
else:
  print(used[dh-1][dw-1])

      
      
      
    
  
  


### FIXED CODE ###

#入力
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
from sys import stdin
s=[stdin.readline() for i in range(h)]

#for i in range(h):
#  s_=list(input())
#  s.append(s_)
#幅優先探索
from collections import deque
q=deque([(ch-1,cw-1)])
used=[[float("INF")]*w for i in range(h)]
used[ch-1][cw-1]=0
X=((-1,0),(1,0),(0,1),(0,-1))
Y=((-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),(-1,-2),(-1,-1),(-1,1),(-1,2),(0,-2),(0,1),(0,2),(1,-2),(1,-1),(1,1),(1,2),(2,-2),(2,-1),(2,0),(2,1),(2,2))
while len(q)>0:
  y,x=q.popleft()
  for dy,dx in X:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]
        q.appendleft((ny,nx))
  for dy,dx in Y:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]+1
        q.append((ny,nx))

if used[dh-1][dw-1]==float("INF"):
  print(-1)
else:
  print(used[dh-1][dw-1])
### BUGGY CODE ###

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

# T[i]に1からiまでの合計値が入っている
# M[i]にiの目があるさいころの期待値が入っている
# T = [0]
# M = [0]
# for j in range(1,1001):
#     T.append(j + T[j-1])
#     K.append(T[j]/j)
# 計算すると(n+1)/2


# M = [0]
# for j in range(1,1001):
#     M.append((j+1)/2)
# # print(K)

# PP = []
# for k in P:
#     PP.append(M[k])
ANS = 0
for i in range(N-K+1):
    TEMP = sum(P[i:i+K])
    if TEMP > ANS:
        ANS = TEMP
print((ANS+K)/2)



### FIXED CODE ###

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

# T[i]に1からiまでの合計値が入っている
# M[i]にiの目があるさいころの期待値が入っている
# T = [0]
# M = [0]
# for j in range(1,1001):
#     T.append(j + T[j-1])
#     K.append(T[j]/j)
# 計算すると(n+1)/2


# M = [0]
# for j in range(1,1001):
#     M.append((j+1)/2)
# # print(K)

# PP = []
# for k in P:
#     PP.append(M[k])
# TEMP = []
ANS = 0
for i in range(N-K+1):
    # TEMP.append(sum(P[i:i+K]))
    if i == 0:
        TEMP = sum(P[i:i+K])
    else:
        TEMP = TEMP - P[i-1] + P[i+K-1]
    if TEMP > ANS:
        ANS = TEMP
# ANS = max(TEMP)
print((ANS+K)/2)
### BUGGY CODE ###

import sys
from fractions import gcd
input = sys.stdin.readline

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

def lcm(x, y):
    return (x * y) // gcd(x, y)
l = a[0]
for i in range(n):
    l = lcm(l, a[i])
sum = 0
for i in range(n):
    sum += l // a[i]
print(sum % 1000000007)


### FIXED CODE ###

import sys
from fractions import gcd
input = sys.stdin.readline

def lcm(x, y):
    return (x * y) // gcd(x, y)
def main():
    n = int(sys.stdin.readline())
    a = list(map(int,input().split()))
    
    l = a[0]
    for i in range(n):
        l = lcm(l, a[i])
    sum = 0
    for i in range(n):
        sum += l // a[i]
    print(sum % 1000000007)
main()