peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r * g * b

for i in range(n):
    for d in range(1, n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1

print(ans)
# Judge status: Accepted
N = int(input())
word = []
flag = 1
for i in range(N):
  st = input()
  if i > 0 :
    if final != st[0]:
      flag = 0
    elif st in word:
      flag = 0
    else:
      final = st[-1]
      word += [st]
  else:
    final = st[-1]
    word += [st]
if flag:
  print("Yes")
else :
  print("No")
# Judge status: Accepted
# coding: utf-8
r, g, b = map(int, input().split())
if (g * 10 + b) % 4 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
n=int(input())
a=int(input())
if n%500 <=a:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
W, a, b = map(int, input().split())
d = b - (a + W) if a < b else a - (b + W)
print(max(d, 0))
# Judge status: Accepted
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
S = [0]*(10**5)

ans = 0
for n in range(N):
    a = A[n]
    S[a-1] += a
    ans += a

Q = int(sys.stdin.readline().rstrip())

for q in range(Q):
    B, C = list(map(int, sys.stdin.readline().rstrip().split()))
    up = C * S[B-1]//B
    down = S[B-1]
    S[C-1] += C * S[B-1]//B
    S[B-1] = 0
    ans = ans + up - down
    print(ans)
# Judge status: Wrong Answer
s = input()
t = input()

n = len(s)
m = len(t)

if n < m:
  print("UNRESTORABLE")
  exit()

for i in range(n-m, -1, -1):
  if s[i] == t[0]:
    if all(s[i+j] == "?" or s[i+j] == t[j] for j in range(1,m)):
      s = s[:i]+t+s[:i+m]
      print(s.replace("?", "a"))
      exit()
print("UNRESTORABLE")
# Judge status: Accepted
N = int(input())
C = list(input())

r = C.count("R")

cnt = 0
for i in range(r):
    if C[i] == "W":
        cnt += 1
        
print(cnt)
# Judge status: Accepted
import numpy as np
from itertools import product

def readlines(n):
    for _ in range(n):
        yield list(map(int, input().split()))

def main():
    N, M, X = map(int, input().split())

    books = np.array(list(readlines(N)))
    ans = np.inf
    for bit in product([0, 1], repeat=N):
        comb_sum = np.dot(np.array(bit), books)
        if all(comb_sum[1:] >= X):
            ans = min(ans, comb_sum[0])

    if ans == np.inf:
        print(-1)
    else: 
        print(ans)
        


main()
# Judge status: Accepted
n = int(input())
def dfs(i,s):
    if i == n:
        print(s)
        return
    ma = 0
    for j in s:
        ma = max(ma,ord(j))
    for j in range(ma - 95):
        dfs(i+1,s+chr(97+j))
    return
dfs(1,"a")
# Judge status: Wrong Answer
num = input()

a = num[0]
b = num[2]
c = num[4]
d = int

d = a
a = b
b = d 
d = c 
c = a
a = d
print(a,b,c)
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))


ans = 1e10
for i in range(-100,101):
    tmp = 0
    for j in a:
        tmp += (i-j)**2
    ans = min(ans,tmp)

print(ans)
# Judge status: Accepted
n = int(input())
a=0
for i in range(1, n+1):
  if i%3!=0 and i%5!=0:
    a=a+i
print(a)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

a.sort()
minus = n
for i in range(n):
  if a[i] >= 0:
    s = i
    break

a = list(map(abs, a))
a.sort()

if minus % 2 == 0:
  print(sum(a))
else:
  print(sum(a) - 2 * a[0])
# Judge status: Wrong Answer
N,K = map(int,input().split())

def replace(N,K):
    if(K == 1 or N==K):
        return 0
    if(N<K):
        return N
    else:
        N = N-(K*(N//K))   
        # while(N-K>0):
        if (N-K<=0 and abs(N-K)<K):
            N = abs(N-K)
                       
            
        return N
print(replace(N,K))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if c>b-a:
    print(c-b-a)
else:
    print(0)
# Judge status: Accepted
from numba import njit


@njit
def solve(a, b, c, x, y):
    ans = 10000000000000000
    for i in range(100000 + 1):
        X = i * (2 * c) + max(0, x - i) * a + max(0, y - i) * b
        ans = min(ans, X)
    return ans


a, b, c, x, y = map(int, input().split())
print(solve(a, b, c, x, y))
# Judge status: Accepted
s, t = input(), input()

if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

possible = []
for i in range(len(s)-len(t)+1):
    temp = s[i:i+len(t)]
    flag = True
    for a, b in zip(t, temp):
        if not (a == b or b == "?"):
            flag = False
    if flag:

        possible.append((s[:i] + t + s[i+len(t):]).replace("?", "a"))

if len(possible) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(possible)[0])
# Judge status: Wrong Answer
print(sum(max(x-y,0)for x,y in zip(*[map(int,t.split())for t in open(0)][1:])))
# Judge status: Wrong Answer
n = int(input())
an = map(int,input().split())
A = list(an)
y=0
for i in range(1, n-1):
    for j in range(i+1, n):
        if(A[i] + A[j] == j -i):
            y=y+1            
print(y)
# Judge status: Accepted
a, b = map(int, input().split())
c = a * b
if(c % 2 == 0):
  print("Even")
else:
  print("Odd")
# Judge status: Accepted
n = int(input())
a = map(int, input().split())
b1, b2, b4 = 0, 0, 0

for i in a:
    if i % 4 == 0:
        b4 += 1
    elif i % 2 == 0:
        b2 += 1
    else:
        b1 += 1
if b2:
    if b1 <= b4:
        print("Yes")
    else:
        print("No")
else:
    if b1 <= b4 + 1:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
def main():
    n, k = map(int, input().split()) 
    h = [int(input()) for _ in range(n)]
    h = sorted(h)
    ans = 10**9
    for i in range(n - k + 1):
        ans = min(ans, h[i + k - 1] - h[i])
        
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
k = int(input())
for c in s[:k]:
	if c != '1':
		print(c)
		break
else:
	print(1)
# Judge status: Accepted
a,b,c = map(int, input().split())

top = b // c
if a%c == 0:
  bottom = a//c - 1
else:
  bottom = a//c

print(top-bottom)
# Judge status: Accepted
def I(): return int(input())
##################################################
X = I()
dp = [0]*(X+1)    #IndexとXを合わせた。dpのIndex範囲:0~X
dp[0] = 1
for i in range(X+1):
    if dp[i]:
        for j in range(100,106):
            if i+j<=X:    #「out of lange」対策。
                dp[i+j] = 1
print(dp[-1])
# Judge status: Accepted
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
if (n-1)%(k-1)!=0:
    ans = (n-1)//(k-1)+1
else:
    ans = (n-1)//(k-1)
print(ans)
# Judge status: Wrong Answer
a,b = map(int,input().split())

print(int((a + b) / 2))
# Judge status: Wrong Answer
mn, mx = float('inf'), -float('inf')
for i in range(5):
    a = int(input())
    mn = min(mn, a)
    mx = max(mx, a)
k = int(input())
if mx - mn < k:
    print(":(")
else:
    print("Yay!")
# Judge status: Accepted
s=input()
s=s.replace("hi","").replace("hihi","").replace("hihihi","").replace("hihihihi","").replace("hihihihi","")
if s == "":
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import sys
import fractions
sys.setrecursionlimit(10**9)

n,m=map(int,input().split())
alist=list(map(int,input().split()))
alist=list(set(alist))

n=len(alist)


def sks(n):
	global alist
	if n == 1:
		return alist[0]
	else:
		tmp=sks(n-1)
		return tmp*alist[n-1]//fractions.gcd(tmp,alist[n-1])

sk = sks(n)
gomi=sk//2

for a in alist:
	if (gomi-a//2)%a != 0:
		print(0)
		sys.exit()

print(int((m+gomi)//sk))
# Judge status: Wrong Answer
import heapq as hq

co = list(map(int,input().split()))
A = list(map(int,input().split()))
N = co[0]
M = co[1]
A = list(map(lambda x: x * (-1),A))
hq.heapify(A)
for i in range(M):
    tmp = hq.heappop(A) //2
    hq.heappush(A,tmp)
list(A)

print(sum(A) * (-1))
# Judge status: Wrong Answer
import math
x, y = map(int, input().split())
print(math.ceil(math.log(y, 2) - math.log(x, 2)))
# Judge status: Wrong Answer
import math
a = list(map(int,input().split()))
#N a[0]
#D a[1]
d = 0
for i in range(a[0]):
    b = list(map(int,input().split()))
    c = math.sqrt(b[0]*b[0]+b[1]*b[1])
    if c >= a[1]: d=d+1
print(d)
# Judge status: Accepted
w, h, n = map(int, input().split())
plots = [list(map(int, input().split())) for _ in range(n)]

w_min, w_max, h_min, h_max = 0, w, 0, h

for i in range(n):
    if plots[i][2] == 1:
        w_min = max(w_min, plots[i][0])
    elif plots[i][2] == 2:
        w_max = min(w_max, plots[i][0])
    elif plots[i][2] == 3:
        h_min = max(h_min, plots[i][1])
    else:
        h_max = min(h_max, plots[i][1])

print(max(0, (w_max - w_min)) * max(0, (h_max - h_min)))
# Judge status: Wrong Answer
N, D = map(int, input().split(" "))
count = 1
for i in range(N):
  X, Y = map(int, input().split(" "))
  if X^2 + Y^2 <= D^2 :
    count += 1
print(count)
# Judge status: Accepted
n, k = list(map(int, input().split(' ')))
abn = [None] * n
for i in range(n):
    abn[i] = list(map(int, input().split(' ')))

abn = sorted(abn, key=lambda ab: ab[0])

ans = -1
temp = 0
i = 0
while True:
    if temp + abn[i][1] >= k:
        ans = abn[i][0]
        break
    temp += abn[i][1]
    i += 1
print(ans)
# Judge status: Wrong Answer
a = list(map(int,input().split()))
n,m = a
if n == m:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a, b = list(map(int, input().split(' ')))

def gcd(a, b):
    def _gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    if a > b:
        return _gcd(a, b)
    else:
        return _gcd(b, a)


print(a // gcd(a, b) * b)
# Judge status: Wrong Answer
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import ceil

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
index_1 = a.index(1)
ans = 0
if index_1 != 0:
    ans += 1
    if index_1 > 3:
        ans += ceil((index_1 - 3) / 2)
if index_1 != (n - 1):
    ans += 1
    if index_1 < (n - 3):
        ans += ceil((n - index_1 - 3) / 2)
print(ans)
# Judge status: Wrong Answer
N=int(input())
B=list(map(int,input().split()))
A=[B[0],B[-1]]
if N==3:
  A.append(min(B))

for i in range(N-3):
  
  if max(B[i],B[i+1])<=B[i+2]:
    A.append(max(B[i],B[i+1]))
  else:
    A.append(B[i+2])
print(sum(A))
# Judge status: Accepted
a, b, x = map(int, input().split())
if a <= x and a + b >= x:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n = list(input())
print('Yes' if n.count('9') >= 1 else 'No')
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
q = int(input())

S = sum(A)
dp = [0] * 100001
for a in A:
    dp[a] += 1


for i in range(q):
    a, b = map(int, input().split())
    dp[b] += dp[a]
    S = S + (b - a) * dp[a]
    print(S)
    dp[a] = 0
# Judge status: Accepted
n, k = map(int, input().split())
print(0 if n % k == 0 else 1)
# Judge status: Wrong Answer
n = list(map(str, input()))
ans = "NO"
for i in range(len(n)):
    if n[i] =="7":
        ans = "YES"
        break
print(ans)
# Judge status: Accepted
import sys

N = int(sys.stdin.readline().strip())

A = []
t = 0
i = 1
while t <= N:
    t += i
    A.append(i)
    i += 1
# print(A) 
for i in A:
    if t - N == i:
        # print("continue", i)
        continue
    else:
        print(i)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

s = input().rstrip()
if "RRR" in s:
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
def resolve():
    a, b = map(int, input().split())
    if a >= 1:
        print('Positive')
    elif len(range(a, 0)) % 2 == 0:
        print('Positive')
    elif len(range(a, 0)) == 1:
        print('Zero')
    else:
        print('Negative')

resolve()
# Judge status: Accepted
n = int(input())
a = [int(input()) for i in range(n)]
ans = -1
x = a[0]
m = 0
for i in range(n):
    m += 1
    if x == 2:
        ans = m
        break
    else:
        x = a[x-1]
print(ans)
# Judge status: Wrong Answer
k, a, b = map(int, input().split())

if k > a+1:
    print(max((k-a-1) // 2 * (b-a) + b + (k-a-1) % 2, k+1))
else:
    print(k+1)
# Judge status: Wrong Answer
s = input()
t = input()
ls= list(s)
lt = list(t)
if len(ls)+1 == len(lt) :
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = list(map(int, input().split()))

total = sum(a)

count = 0

valid = total / (4 * m)

for i in a:
    if i > valid:
        count += 1

if count > m:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a,b = list(map(int, input().strip().split()))
c=100*a+b
d=(c**0.5)//1
if d**2==c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n=int(input())
count=[0]*n
a=list(map(int,stdin.readline().split()))
for i in a:
    count[i-1]+=1
for i in count:
    print(i)
# Judge status: Wrong Answer
n,m = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(m):
  b,c = map(int,input().split())
  A.extend([b for _ in range(c)])
A.sort(reverse = True)

print(sum(A[:n+1]))
# Judge status: Accepted
n,a=int(input()),list(map(int,input().split()))
b=[a[1::2][::-1]+a[::2],a[0::2][::-1]+a[1::2]][n%2]
print(*b,sep=' ')
# Judge status: Accepted
import numpy as np
N, K = list(map(int,input().split()))
tmp = np.zeros(2)
tmp[0] = N % K
tmp[1] = -N % K
print(int(tmp.min()))
# Judge status: Wrong Answer
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a-1] = 1
    count = 0
    for j in range(1, M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))


B = 0
C = 0
for i in range(N):
    B += A[i]
    C += A[i]**2

ans = (((B**2) - C) / 2) % (10 ** 9 + 7)
print(int(ans))
# Judge status: Accepted
N = int(input())
print(-(-N // 2) / N)
# Judge status: Accepted
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))
# Judge status: Accepted
N,K=map(int, input().split());print((N-K+2)*((N-K+1)*(N+2*K)+6)//6%(10**9+7))
# Judge status: Accepted
import sys
input = sys.stdin.readline

S = input().rstrip('\n')
print(S.rfind("Z") - S.find("A") + 1)
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline
#input = sys.stdin.readline


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n,k=map(int,input().split())
	x=list(map(int,input().split()))

	ans=10**18

	for i in range(n):
		try:
			l=x[i]
			r=x[i+k-1]
			if r<0:
				ans=min(ans,-l)
			elif l>0:
				ans=min(ans,r)
			else:
				ans=min(ans,r-l+min(-l,r))
		except:
			pass
	print(ans)



if __name__ == "__main__":
	main()
# Judge status: Wrong Answer
s = int(input())

t = set([])
for i in range(1,10**6+1):
  if s%2==0:
    s//=2
  else:
    s=s*3+1
  if s in t:
    print(i)
    break
  else:
    t.add(s)
# Judge status: Accepted
def mainFunc():
    N = int(input())
    matrix = [[0 for i in range(10)] for i in range(10)]
    for i in range(1, N + 1):
        start = int(str(i)[0])
        end = int(str(i)[-1])
        matrix[start - 1][end - 1] += 1
    
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += matrix[i][j] * matrix[j][i]

    print(ans)


mainFunc()
# Judge status: Wrong Answer
x = int(input())

print(-(-x*2//11))
# Judge status: Accepted
N=int(input())
if N>=30:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
h,a = map(int,input().split())
if h%a==0:
  print(h//a)
else:
  print(h//a+1)
# Judge status: Wrong Answer
a=int(input())
p=list(map(int,input().split()))
k=1
for i in range(a-1):
    if p[i+1]<p[i]:
        k+=1
print(k)
# Judge status: Accepted
n, a, b = map(int,input().split())

ans = 0
for i in range(n+1):
    j = i
    k = 0
    while j != 0:
        k += j % 10
        j //= 10

    if k <= b and k >= a:
        ans += i

print(ans)
# Judge status: Accepted
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

s = '7' * len(str(K))
if int(s) < K:
    s += '7'
ans = len(s)
s = int(s)

while True:
    s = s % K
    if s == 0:
        print(ans)
        exit()
    s = s * 10 + 7
    ans += 1
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
four = 0
two = 0
el = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0 :
        two += 1
    else:
        el += 1

if two == 0:
    if four + 1 >= el:
        print("Yes")
    else:
        print("No")
else:
    if four >= el:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import numpy as np
p = np.array(list(map(int, input().split())))

cnt = 0
mem = []
flag = True
while (p % 2).sum() == 0:
    a = p[1] // 2 + p[2] // 2
    b = p[0] // 2 + p[2] // 2
    c = p[1] // 2 + p[0] // 2
    
    p = np.array([a, b, c])
    if (a,b,c) in mem:
        flag = False
        break
    else:
        mem.append((a,b,c))
        
    cnt += 1

print(cnt if flag else -1)
# Judge status: Accepted
#みんなのプロコン2019-C
k,a,b = map(int,input().split())

if b - a <= 2:
    print(k+1)
else:
    r = k - (a-1)
    ans = max(0,a + r//2*(b-a)+r%2)
    print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
k =  0 
if (a + b) % 2 == 0:
    print(int((a+b)/2))
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
N, M = map(int, input().split())
L = []
ans = 0
for i in range(N):
  L.append(list(map(int,input().split())))
L.sort()
for i in range(N):
  if L[i][1]<=M:
    M -= L[i][1]
    ans += L[i][0]*L[i][1]
  else:
    ans += L[i][0]*M
    break
print(ans)
# Judge status: Wrong Answer
N,M=list(map(int, input().split()))
if N>1 and M>1:
  print(N*M - (N-2)*(M-2))
else:
  print(N*M-2)
# Judge status: Accepted
X,K,D=map(int,input().split())
X=abs(X)
if X-K*D>=0:
    print(X-K*D)
else:
    d,m=divmod(X,D)
    if (K-d)%2==0:
        print(m)
    else:
        print(abs(m-D))
# Judge status: Accepted
N, X = map(int, input().split())
L = list(map(int, input().split()))

d = 0
ans = 1

for i in range(N):
    d += L[i]
    if d <= X:
        ans += 1
    else:
        break

print(ans)
# Judge status: Wrong Answer
a, b = input().split()
ab = int(str(a)+str(b))
ans = 'No'
for i in range(1, 101):
  if i*i == ab:
    ans='Yes'
    break
print(ans)
# Judge status: Wrong Answer
s = str(input())
i = 0
while(1):
    if len(s) - i < 5:
        break
    if s[i:i+5] == "erase" or s[i:i+5] == "dream":
        i += 5
        if s[i:i+2] == "er":
            i += 2
    else:
        print("No")
        exit()
print("YES" if i == len(s) else "NO")
# Judge status: Wrong Answer
from collections import Counter
N, K = map(int, input().split())
A = Counter(input().split())
print(A)

print(sum(sorted(A.values(), reverse=True)[K:]))
# Judge status: Accepted
N, M = map(int, input().split())
list=[]
for i in range(M):
    p, y =map(int, input().split())
    list.append([p, y, i])
list.sort(key=lambda list:(list[0], list[1]))
list[0][1]=1
for i in range(M-1):
    if list[i][0] != list[i+1][0]:
        list[i+1][1] = 1
    else:
        list[i+1][1] = list[i][1] + 1 
list.sort(key=lambda list:(list[2]))
for i in range(M):
    print(str(list[i][0]).zfill(6)+str(list[i][1]).zfill(6))
# Judge status: Wrong Answer
a,b,c = map(int, input().split())
print((a-c) // b)
# Judge status: Wrong Answer
N = int(input())


def read(): return list(map(int, input().split()))


data = read()
flag = True
for i in data:
    if (i % 2 == 0):
        if (i % 3 != 0 and i % 5 != 0):
            flag = False
            break
if (flag == True):
    print('APPROVED')
else:
    print('DEFINED')
# Judge status: Accepted
n, q = map(int,input().split())
s = list(input())
lr = [list(map(int,input().split())) for i in range(q)]
ans = [0]
x = 0

for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        x += 1
    ans.append(x)

for i in lr:
    l = i[0]
    r = i[1]
    print(ans[r-1] - ans[l-1])
# Judge status: Wrong Answer
a,b,c,k = map(int,input().split())

print(a-(1*(k-a-b)))
# Judge status: Accepted
_,*l=open(0).read().split()
[print(i + 1)for i in sorted(range(len(l)//2),key=lambda i:(l[i*2],-int(l[i*2+1])))]
# Judge status: Accepted
a , b , c , k = map(int, input().split())
 
if  a > k:
  print(k)
elif a + b >= k:
  print(a)
else:
  print(2*a - k + b)
# Judge status: Accepted
# 最小公倍数
from fractions import gcd
from functools import reduce
def lcm (x, y):
    return (x * y) // gcd(x, y)

# 最小公倍数(リスト)
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

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

lcm_A = lcm_list(A)

ans = 0
for i in range(N):
    ans += lcm_A // A[i]

print(ans % mod)
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
d_min = 99999
ans = 0
for i in range(n):
    d = abs(t - a - h[i] * 0.006)
    if d < d_min:
        d_min = d
        ans = i + 1
print(ans)
# Judge status: Accepted
a = ord(input())
if a>= ord("a") and a<=ord('z'):
    print('a')
else:
    print("A")
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))

l=[l[i]-(i+1) for i in range(n)]

from statistics import median
z=int(median(l))

x=0
for j in range(n):
    x+=abs(l[j]-z)

print(x)
# Judge status: Wrong Answer
import itertools
N=10**100
n,k=map(int,input().split())
li=[]
for i in range(n+2):
    li.append(i)
counter=0
for i in itertools.combinations(li,k):
    counter+=1
print(counter)
# Judge status: Wrong Answer
N = input()
A = input()
y = N/500
if y == 0:
    print "Yes"
elif N-500*y < A:
    print "Yes"
else:
    print "No"
# Judge status: Accepted
x = list(map(int, input().split()))
print(15 - sum(x))
# Judge status: Wrong Answer
def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return True
        i += 1

a = int(input())
while True:
    a += 1
    if isPrime(a):
        print(a)
        break
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

ab = a
cd = c
ab_flag = 0
cd_flag = 0

if abs(a) < abs(b):
    ab = b
    ab_flag = 1

if abs(c) < abs(d):
    cd = d
    cd_flag = 1

ans = ab * cd

if ans < 0:
    if a > 0:
        ans = a * d
    elif c > 0:
        ans = b * c
    elif a > 0 and d > 0:
        ans = b * d
    elif c > 0 and b > 0:
        ans = d * b

print(str(ans))
# Judge status: Wrong Answer
import collections
n = int(input())

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

b = collections.Counter(a)

ans = 0

for k,v in b.items():
    ans += min(v,abs(k-v))
    
print(ans)
# Judge status: Accepted
n,m= list(map(int,input().split(" ")))
arr = list(map(int,input().split(" ")))
if(sum(arr)>n):
    print(-1)
elif(sum(arr)==n):
    print(0)
else:
    print(n-sum(arr))
# Judge status: Wrong Answer
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a


n = int(input())
a = list(map(int, input().strip().split()))
x = a[1]

for i in range(2, n):
    x = gcd(x, a[i])

res = x
x = a[0]

for i in range(1, n-1):
    y = x
    for j in range(i+1, n):
        y = gcd(y, a[j])
    if res < y:
        res = y
    x = gcd(x, a[i])

y = gcd(x, a[n-1])
if res < y:
    res = y
print(res)
# Judge status: Wrong Answer
import collections
N = int(input())
lsS = []
for i in range(N):
    lsS.append(''.join(sorted(input())))

counter = collections.Counter(lsS)
n=0
for i in counter.values():
    if i > 1:
        n+=1
print(n)
# Judge status: Accepted
L,R=map(int,input().split())
M=2019;l=L%M;r=R%M
print(0 if l>r or R-L>671 else min(i*j%M for i in range(l,r) for j in range(i+1,r+1)))
# Judge status: Accepted
a, b, k  = map(int, input().split())
c = 0
ans = []
if a > b:
  c = b
else:
  c = a

for i in range(1, c+1):
  if a % i == 0 and b % i == 0:
    ans.append(i)
  else:
    continue


print(ans[-k])