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

import numpy as np

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

exps = []
ans = []

for ii in range(N):  
  p[ii] = int(p[ii])
  exps.append(p[ii]*(p[ii]+1)/(2*p[ii]))

for ii in range(K-1,N):
  ans.append(np.sum(exps[ii-K+1:ii+1]))
    

print(np.max(ans))

### FIXED CODE ###

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

res = []

res.append((sum(range(1,p[0]+1)))/p[0])

for i in range(1,N):
  #res.append(res[i-1] + p[i]*(p[i]+1)/(2*p[i]))
  res.append(res[i-1] + 0.5*(p[i]+1))
  #res.append(res[i-1] + 1 + 0.5*(p[i]-1))

ans=res[K-1]

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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  s=[list(S()) for _ in range(h)]

  ans=0
  for i in range(h):
    for j in range(w):
      if s[i][j]=='#':
        continue

      _ans=-1
      for a in range(i)[::-1]:
        if s[a][j]=='.':
          _ans+=1
        else:
          break
      for a in range(i,h):
        if s[a][j]=='.':
          _ans+=1
        else:
          break
      for a in range(j)[::-1]:
        if s[i][a]=='.':
          _ans+=1
        else:
          break
      for a in range(j,w):
        if s[i][a]=='.':
          _ans+=1
        else:
          break

      ans=max(ans,_ans)
  return ans

# main()
print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  s=[S() for _ in range(h)]

  L=[[0 for _ in range(w)]for __ in range(h)]
  R=[[0 for _ in range(w)]for __ in range(h)]
  D=[[0 for _ in range(w)]for __ in range(h)]
  U=[[0 for _ in range(w)]for __ in range(h)]

  for i in range(h):
    for j in range(w):
      if s[i][j]=='#':
        L[i][j]=0
        U[i][j]=0
        continue

      if i==0:
        U[i][j]=1
      else:
        U[i][j]=U[i-1][j]+1

      if j==0:
        L[i][j]=1
      else:
        L[i][j]=L[i][j-1]+1

  for i in range(h)[::-1]:
    for j in range(w)[::-1]:
      if s[i][j]=='#':
        R[i][j]=0
        D[i][j]=0
        continue

      if i==h-1:
        D[i][j]=1
      else:
        D[i][j]=D[i+1][j]+1

      if j==w-1:
        R[i][j]=1
      else:
        R[i][j]=R[i][j+1]+1

  ans=0
  # print(R,L,D,U)
  for i in range(h):
    for j in range(w):
      ans=max(ans,R[i][j]+L[i][j]+U[i][j]+D[i][j]-3)

  return ans

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

x1 = input()
x2 = [int(i) for i in input().split(" ")]

result = 1
for xv in x2:
  result = xv * result

if 10**18 < result : result = -1
print(result) 


### FIXED CODE ###

x1 = input()
x2 = [int(i) for i in input().split(" ")]

result = 0
if 0 in x2:
  None 
else:
  result = 1
  for xv in x2:
     result = xv * result
  
     if 10**18 < result : 
        result = -1
        break


print(result)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
def itercomb(n,k):
    _a = 2**k-1
    yield 2**k-1
    while 1:
        _x = _a & -_a
        _y = _a + _x
        _a = (((_a & ~_y) // _x) >> 1) | _y
        if _a >= 2**n: break
        yield _a

MOD=10**9+7
n=int(input())
A= [[int(i) for i in input().split()] for j in range(n)]

dp = [0]*(2**n)
dp[0] = 1

for m in range(1,n+1):
    for a in itercomb(n,m):
        #print(a)
        #if bin(a).count("1") != m: continue
        dp[a] = sum(dp[a-2**c] for c in range(n) if 2**c&a != 0 and A[m-1][c]==1)%MOD


print(dp[2**n-1])

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

def itercomb(n,k):
    _a = (1<<k)-1
    yield _a
    while 1:
        _x = _a & -_a
        _y = _a + _x
        _a = (((_a & ~_y) // _x) >> 1) | _y
        if _a >= _ALL: break
        yield _a

n=int(input())
A= [[int(i) for i in input().split()] for j in range(n)]

MOD=10**9+7
_ALL=1<<n
dp = [0]*(_ALL)
dp[0] = 1

for m in range(1,n+1):
    for a in itercomb(n,m):
        for c,i in enumerate(A[m-1]):
            if (1<<c)&a and i:
                dp[a] += dp[a^(1<<c)]
                if dp[a] > MOD:
                    dp[a] -= MOD


#print(dp)
print(dp[2**n-1])
### BUGGY CODE ###

s = input()
t = input()
if t in s:
    print(0)
else:
    ans = len(t)
    for i in range(len(t)):
        for j in range(len(s)):
            if t[i] == s[j]:
                if ((len(t) - i) <= (len(s) - j)) and i <= j:
                    k = i + 1
                    l = j + 1
                    cnt1 = 0
                    while k < len(t):
                        if t[k] != s[l]:
                            cnt1 += 1
                        k += 1
                        l += 1
                    k = i - 1
                    l = j - 1
                    cnt2 = 0
                    while k >= 0:
                        if t[k] != s[l]:
                            cnt2 += 1
                        k -= 1
                        l -= 1
                    ans = min(ans, cnt1 + cnt2)  
                 
               
    print(ans)

### FIXED CODE ###

s = input()
t = input()
if t in s:
    print(0)
else:
    ans = len(t)
    for i in range(len(s) - len(t) + 1):
        cnt = 0
        k = i
        l = 0
        while l < len(t) and k < len(s):
            if s[k] != t[l]:
                cnt += 1 
            k += 1
            l += 1    
        ans = min(ans, cnt)
    print(ans)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = A[i][j]-B[i][j]
M = 80*(H+W)
dp = [set() for j in range(H)]
c = C[0][0]
dp[0].add(c)
dp[0].add(-c)
for i in range(1, H):
    c = C[i][0]
    for j in dp[i-1]:
        dp[i].add(j+c)
        dp[i].add(j-c)
for i in range(1, W):
    dp1 = [set() for j in range(H)]
    c = C[0][i]
    for k in dp[0]:
        dp1[0].add(k+c)
        dp1[0].add(k-c)
    for j in range(1, H):
        c = C[j][i]
        for k in dp[j]:
            dp1[j].add(k+c)
            dp1[j].add(k-c)
        for k in dp1[j-1]:
            dp1[j].add(k+c)
            dp1[j].add(k-c)
    dp = dp1

ans = min(abs(i) for i in dp[-1])
print(ans)

        









### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])
M = 80*(H+W)
dp = [[0 for i in range(W)] for j in range(H)]
c = C[0][0]
dp[0][0]+=(1<<(c+M))|(1<<(M-c))
for s in range(1, H+W):
    for b in range(max(s-H+1, 0), min(s+1, W)):
        a = s-b
        c = C[a][b]
        if a>=1:
            d = dp[a-1][b]
            dp[a][b]|=(d<<c)|(d>>c)
        if b>=1:
            d = dp[a][b-1]
            dp[a][b]|=(d<<c)|(d>>c)
ans = 10**10
d = dp[-1][-1]
for i in range(0, M*2+1):
    if 1<<i&d:
        ans = min(ans, abs(i-M))
print(ans)
### BUGGY CODE ###

N=int(input())
s=[]
cnt=dict()
for _ in range(N):
    tmp=list(input())
    stmp=sorted(tmp)
    if(( stmp in s)==True):
        n=s.index(stmp)
        if((n in cnt.keys())==False):
            cnt[n]=1
        else:
            cnt[n]+=1
    else:
        s.append(stmp)


total=0
for value in cnt.values():
    total+=(1+value)*value//2

print(total)

### FIXED CODE ###

N=int(input())
s=[]
cnt=dict()


for _ in range(N):
    tmp=list(input())
    sotmp=sorted(tmp)
    stmp=''.join(sotmp)
    s.append(stmp)

ss=sorted(s)

for word in ss:
    if((word in cnt.keys())==False):
        cnt[word]=0
    else:
        cnt[word]+=1


total=0
for value in cnt.values():
    total+=(1+value)*value//2

print(total)
### BUGGY CODE ###

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

import bisect

i=bisect.bisect_left(X,0)
L=max(0, bisect.bisect_right(X,0)-K)
R=min(N-1, bisect.bisect_left(X,0)+K-1)

ans=float('inf')
for i in range(L,R-K+2):
    t=0
    s=X[i:i+K]
    if s[0]<0:
        t+=abs(s[0])
    if 0<X[-1]:
        t+=t+s[-1]
    # print(s,t)
    ans=min(ans,t)
print(ans)

### FIXED CODE ###

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

import bisect

i=bisect.bisect_left(X,0)
L=max(0, bisect.bisect_right(X,0)-K)
R=min(N-1, bisect.bisect_left(X,0)+K-1)

ans=float('inf')

for i in range(L,R-K+2):
    t=0
    l=X[i]
    r=X[i+K-1]
    if r<=0:
        t=abs(l)
    elif 0<=l:
        t=r
    else:
        t=min(abs(l),r)*2+max(abs(l),r) 
    # print(X[i:i+K],t)
    ans=min(ans,t)
print(ans)
### BUGGY CODE ###

from collections import deque

def main():
  s = deque(input())
  q = int(input())
  query = tuple(input() for i in range(q))

  for i in range(q):
    temp = query[i].split()
    if int(temp[0]) == 1:
      s.reverse()
    else:
      if int(temp[1]) == 1:
        s.appendleft(temp[2])
      else:
        s.append(temp[2])

  print(''.join(s))

if __name__ == '__main__':
  main()


### FIXED CODE ###

from collections import deque

def main():
  rev = False
  s = deque(input())
  q = int(input())
  query = tuple(input() for i in range(q))

  for i in range(q):
    temp = query[i].split()
    if int(temp[0]) == 1:
      rev = not rev
    else:
      if (int(temp[1]) == 1 and (not rev)) or (int(temp[1]) == 2 and rev):
        s.appendleft(temp[2])
      else:
        s.append(temp[2])

  if rev:
    s.reverse()

  print(''.join(s))

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

n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])


for t in T:
	while(D[0] < t):
		D.pop(0)
	if D[0] == t:
		D.pop(0)
	else:
		print("NO")
		exit(0)
print("YES")

### FIXED CODE ###

n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])

i = 0
for t in T:
	while(D[i] < t):
		i += 1
	if D[i] == t:
		i += 1
	else:
		print("NO")
		exit(0)
print("YES")
### BUGGY CODE ###

import functools
import operator
n=int(input())
li = list(map(int,input().split()))
result = functools.reduce(operator.mul, li)
if result >10**18: print(-1)
else:print(result)

### FIXED CODE ###

import numpy as np
n = int(input())
target = 1
List = list(map(int,input().split()))
if 0 in List:
  print(0)
  exit()
for i in range(len(List)):
  target*=List[i]
  if target>10**18 :
    print(-1)
    exit()
print(target)
### BUGGY CODE ###

n, m = (int(x) for x in input().split())
l = []
d = {}
for _ in range(m):
    l.append([int(x) for x in input().split()])
for i in range(m):
    k = str(l[i][0])
    if k not in d.keys():
        d[k] = [l[i][1]]
    else:
        d[k].append(l[i][1])
for key in d.keys():
    d[key].sort()
for li in l:
    print(str(li[0]).zfill(6) + str(d[str(li[0])].index(li[1]) + 1).zfill(6))

### FIXED CODE ###

import bisect as bis
n, m = map(int, input().split())
idx = lambda x: x-1
p, y = [], []
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i, j in zip(p, y):
    val[idx(i)].append(j)
for i in range(n):
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])
    print(str(v).zfill(6) + str(id).zfill(6))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
counter = 0
if R < G:
  R, G = G, R
if G < B:
  G, B = B, G
if R < G:
  R, G = G, R

r = 0
while r * R <= N:
  g = 0
  while g * G <= N:
    b = (N - r*R - g*G)/B 
    if b < 0:
      break
    elif b == int(b):
      counter += 1
    g += 1
  r += 1
print(counter)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
counter = 0
if R < G:
  R, G = G, R
if G < B:
  G, B = B, G
if R < G:
  R, G = G, R
r = 0
while r * R <= N:
  g = 0
  if B == 1:
    counter += (N - r*R)//G + 1
    r += 1
    continue
  while g * G <= N:
    b = (N - r*R - g*G)/B 
    if b < 0:
      break
    elif b == int(b):
      counter += 1
    g += 1
  r += 1
print(counter)
### BUGGY CODE ###

import numpy as np

N, M=map(int, input().split())
A=list(map(int, input().split()))
for i in range(M):
  B, C=map(int, input().split())
  A=A+[C for i in range(B)]
  
A=np.sort(A)
print(int(np.sum(A[-N:])))

### FIXED CODE ###

from collections import defaultdict

cnt=defaultdict(int)

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

for i in range(N):
  cnt[A[i]]+=1

tmp=[0]*M
for i in range(M):
  B, C=map(int, input().split())
  cnt[C]+=B
  tmp[i]=C
A+=tmp

tmp=list(cnt.keys())
tmp.sort()
j=-1
out=0
while N>0:
  if cnt[tmp[j]]<=N:
    out+=tmp[j]*cnt[tmp[j]]
    N-=cnt[tmp[j]]
  else:
    out+=tmp[j]*N
    N=0
    
  j-=1
print(out)
### BUGGY CODE ###

from functools import reduce
import operator
import heapq
def SME(start,end):
    A = []
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        for i in range(L):
            idx = a[1] + i
            try :
                if not ANS[idx]:
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if not ANS[i] : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if not ANS[i] : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS
 
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
parameter = 0.99065
INIT = None
ANS = [INIT]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=998244353
    N=I()
    A=LI()
    MA=max(A)
    x=[0]*(MA+1)
    
    #数列x[i]はi*(iの個数)
    for i in range(N):
        x[A[i]]+=A[i]
        
    #print(x)
    
    #上位集合のゼータ変換
    for k in range(1,MA+1):
        for s in range(k*2,MA+1,k):#sが2kからkずつ増える=>sはkの倍数(自分自身を数えないため，2kから)
            x[k]=(x[k]+x[s])%mod
    
    #print(x)
    #この段階でx[i]はiを約数に持つやつの和(個数も加味している)
    
    #積演算
    for i in range(MA+1):
        x[i]=(x[i]*x[i])%mod
        
    #print(x)
    
    
    #メビウス変換で戻す
    for k in range(MA,0,-1):
        for s in range(k*2,MA+1,k):
            x[k]=(x[k]-x[s])%mod
            
    #この段階でx[i]はiをgcdに持つもの同士をかけたものの和
    #print(x)
    
    #gcdでわる
    for i in range(2,MA+1):
        x[i]=(x[i]*pow(i,mod-2,mod))%mod
        
    #この段階でx[i]はiをgcdに持つもの同士のlcaの和
    #print(x)
    
    """
    for i in range(MA+1):
        if x[i]!=0:
            print(i,x[i])"""
    
    
    ans=0
    for i in range(1,MA+1):
        ans=(ans+x[i])%mod
        #xの和を取る
        
    for i in range(N):
        ans=(ans-A[i])%mod
        #A[i],A[i]の組を除去する．A[i]動詞のくみはlcaがA[i]になる
        
    ans=(ans*499122177)%mod#A[i]*A[j] と　A[j]*A[i]の被り除去
    
    print(ans)
        
    
    

main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=998244353
    N=I()
    A=LI()
    MA=max(A)
    x=[0]*(MA+1)
    
    #数列x[i]はi*(iの個数)
    for i in range(N):
        x[A[i]]+=A[i]
        
    #print(x)
    
    #上位集合のゼータ変換
    for k in range(1,MA+1):
        for s in range(k*2,MA+1,k):#sが2kからkずつ増える=>sはkの倍数(自分自身を数えないため，2kから)
            x[k]=(x[k]+x[s])%mod
    
    #print(x)
    #この段階でx[i]はiを約数に持つやつの和(個数も加味している)
    
    #積演算
    for i in range(MA+1):
        x[i]=(x[i]*x[i])%mod
        
    #print(x)
    
    
    #メビウス変換で戻す
    for k in range(MA,0,-1):
        for s in range(k*2,MA+1,k):
            x[k]=(x[k]-x[s])%mod
            
    #この段階でx[i]はiをgcdに持つもの同士をかけたものの和
    #print(x)
    
    #gcdでわる
    ans=0
    for i in range(1,MA+1):
        if x[i]!=0:
            x[i]=(x[i]*pow(i,mod-2,mod))%mod
            ans=(ans+x[i])%mod
        
    #この段階でx[i]はiをgcdに持つもの同士のlcaの和
    #print(x)
        
    ans=(ans-sum(A))%mod
    #A[i],A[i]の組を除去する．A[i]動詞のくみはlcaがA[i]になる
       
    """ 
    ans=(ans*pow(2,mod-2,mod))%mod#A[i]*A[j] と　A[j]*A[i]の被り除去
    print(pow(2,mod-2,mod))=499122177
    """
    ans=(ans*499122177)%mod
    
    print(ans)
        
    
    

main()
### BUGGY CODE ###

n, m = sorted([int(x) for x in input().split()])
gap = m - n
if gap > 1:
    print(0)
    exit()
mod = 10 ** 9 + 7
f = f_n = 1
for i in range(2, m + 1):
    f *= i
    if i == n:
        f_n = f % mod
f_m = f % mod
ans = f_n * f_m % mod
if gap == 0:
    ans = ans * 2 % mod
print(ans)

### FIXED CODE ###

from math import factorial
n, m = [int(x) for x in input().split()]
temp = abs(n - m)
if temp > 1:
    print(0)
    exit()
mod = 10 ** 9 + 7
f_n = factorial(n) % mod
f_m = factorial(m) % mod
ans = f_n * f_m % mod
if temp == 0:
    ans = ans * 2 % mod
print(ans)
### BUGGY CODE ###

n = int(input())
lst = []

while n>0:
  lst.append(n%10)
  n //= 10

lst.reverse()

if sum(lst)%9 == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())

if n%9==0:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

import copy
N=int(input())
A = [int(input()) for i in range(N)]
big=max(A)
flag=0
for i in range(N):
    if A[i]==big:
        if flag==0:
            flag==1
            hoge=copy.copy(A)
            hoge.pop(i)
            bigger=max(hoge)
            if bigger==big:
                print(big)
            else:
                print(bigger)
        else:
            print(bigger)
    else:
        print(big)

### FIXED CODE ###

N=int(input())
A = [int(input()) for i in range(N)]
B=sorted(A)
big=max(A)
flag=0
big2=B[-2]
for i in A:
    if i==big:
        print(big2)
    else:
        print(big)
### BUGGY CODE ###

def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める
    計算量: O(Nlog)
    """
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
MOD = 10**9 + 7
a = list(map(int, input().split()))
lcm_ = multi_lcm(a)
ans = 0
for i in range(n):
    ans += lcm_ * pow(a[i], MOD - 2, MOD)
    ans %= MOD
print(ans % MOD)


### FIXED CODE ###

def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める
    計算量: O(Nlog)
    """
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
MOD = 10**9 + 7
a = list(map(int, input().split()))
lcm_ = multi_lcm(a)
ans = 0
for i in range(n):
    ans += lcm_ * pow(a[i], MOD - 2, MOD)
print(ans % MOD)
### BUGGY CODE ###

from itertools import permutations

n,c = map(int, input().split())
cln = list(range(0,c))
cpl = list(permutations(cln,3))

dl = []
for _ in range(c):
    row = list(map(int, input().split()))
    dl.append(row)

cl = []
for _ in range(n):
    row = list(map(int, input().split()))
    cl.append(row)

ans = 10**10
for cp in cpl:
    cost = 0
    for i in range(n):
        for j in range(n):
            val3 = (i+j+2)%3
            target_c = cp[val3]
            orig_c = cl[i][j]-1
            cost += dl[orig_c][target_c]
    ans = min(ans,cost)

print(ans)

### FIXED CODE ###

from itertools import permutations

n,c = map(int, input().split())
cln = list(range(0,c))
cpl = list(permutations(cln,3))

dl = []
for _ in range(c):
    row = list(map(int, input().split()))
    dl.append(row)

cl = []
for _ in range(n):
    row = list(map(int, input().split()))
    cl.append(row)


costs = [ [0]*c for _ in range(3) ]
for i in range(n):
    for j in range(n):
        for target_c in range(c):
            val3 = (i+j+2)%3
            orig_c = cl[i][j]-1
            cost = dl[orig_c][target_c]
            costs[val3][target_c] += cost


ans = 10**10
for cp in cpl:
    cost = costs[0][cp[0]] + costs[1][cp[1]] + costs[2][cp[2]]
    ans = min(ans,cost)

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

def main():
    n = int(input())
    s = input()
    res = 0
    for i in range(n):
        for j in range(i+1, n):
            if s[i] == s[j]:
                continue
            for k in range(j+1, n):
                if (j-i) == (k-j):
                    continue
                if s[i] == s[k] or s[j] == s[k]:
                    continue
                res += 1
    print(res)

if __name__ == '__main__':
    main()



### FIXED CODE ###

from itertools import permutations

def main():
    n = int(input())
    s = input()
    res = 0
    r = 0
    g = 0
    b = 0
    for i, c in enumerate(s):
        if c == 'R':
            r += 1
        elif c == 'G':
            g += 1
        else:
            b += 1
    
    rgb = []
    for t in permutations('RGB'):
        rgb.append(''.join(t))

    cnt = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            k = 2*j - i 
            if k >= n:
                break
            if (s[i] + s[j] + s[k]) in rgb:
                cnt += 1
    print(r*g*b - cnt)


if __name__ == '__main__':
    main()