Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))

ans_root = K
for i range(N):
    if i==0:
        root = A[N-1] - A[0]
    else:
        root = A[i-1]+K - A[i]
    if ans_root > root:
        ans_root = root
print(ans_root)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))

ans_root = K
for i in range(N):
    if i==0:
        root = A[N-1] - A[0]
    else:
        root = A[i-1]+K - A[i]
    if ans_root > root:
        ans_root = root
print(ans_root)
Buggy python submission (verdict: Runtime Error):
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        lis.append([x, y, h])
        sx, sy, sh = x, y, h

for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > abs(cx - x) + abs(cx + y):
                break
            if K == len(lis) - 1:
                print(cx, cy, hight)
                exit()

Fixed submission:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        high = sh + abs(sx - i) + abs(sy - j)
        judge = -1
        for x, y, h in lis:
            if h > 0 and high != h + abs(x - i) + abs(y - j):
                judge = 0
                break
        if judge == 0:
            continue
        for x, y, h in lis:
            if h == 0 and high > abs(x - i) + abs(y - j):
                judge = 0
                break
        if judge == 0:
            continue
        
        print(i, j, sh + abs(sx - i) + abs(sy - j))
        exit()
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
output = []
for i in range(H-1):
    for j in range(W):
        if a[i][j] % 2 == 1:
            a[i+1][j] += 1
            output.append([i+1, j+1, i+2, j+1])

for i in range(W):
    if a[-1][i] % 2 == 1:
        a[-1][i+1] += 1
        output.append([H, i+1, H, i+2])
print(len(output))
for o in output:
    for xy in o:
        print(xy, end=' ')
    print()

Fixed submission:
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
output = []
for i in range(H-1):
    for j in range(W):
        if a[i][j] % 2 == 1:
            a[i+1][j] += 1
            output.append((i+1, j+1, i+2, j+1))

for i in range(W-1):
    if a[-1][i] % 2 == 1:
        a[-1][i+1] += 1
        output.append((H, i+1, H, i+2))
print(len(output))
for y, x, ay, ax in output:
    print(y, x, ay, ax)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = list(map(int, input().split()))
sort_X = sorted(X)

for i in range(N):
    copy_X = sort_X.copy()
    copy_X.remove(X[i])
    
    print(copy_X[(N-1)//2])

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
sort_X = sorted(X)
a = sort_X[N//2-1]
b = sort_X[N//2]
for i in range(N):
    if X[i] < b:
        print(b)
    else:
        print(a)
Buggy python submission (verdict: Runtime Error):
N = input()

if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[1] == N[3]):
    print('Yes')
else:
    print('No')

Fixed submission:
print(48 - int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
import math
Q = int(input())
l_r = [list(map(int, input().split())) for _ in range(Q)]

def isprime(n):
    if n <= 1:
        return False
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True
def like(x):
    if isprime(x) and isprime((x+1)//2):
        return True
    
    return False

x_list = [0] * (10 ** 5)
for i in range(1, 10**5, 2):
    if like(i):
        x_list[i] = 1

for i in range(Q):
    print(sum(x_list[l_r[i][0]: l_r[i][1]+1]))

Fixed submission:
import math
import sys
sys.setrecursionlimit(10000000)
Q = int(input())
l_r = [list(map(int, input().split())) for _ in range(Q)]

prime = []
def isprime(n):
    if n in prime:
        return True
    if n <= 1:
        return False
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    
    return True


def like(x):
    if isprime(x) and isprime((x+1)//2):
        return True
    
    return False

x_dict = {1:0}
def count_like(x):
    if x in x_dict:
        return x_dict[x]
    x_dict[x] = count_like(x-1) + like(x)
    return x_dict[x]

for i in range(Q):
    print(count_like(l_r[i][1]) - count_like(l_r[i][0]) + int(like(l_r[i][0])))

Buggy python submission (verdict: Runtime Error):
import sympy
Q = int(input())
l_r = [list(map(int, input().split())) for _ in range(Q)]

def like(x):
    if sympy.isprime(x) and sympy.isprime((x+1)//2):
        return True
    
    return False

x_list = [0] * (10 ** 5)
for i in range(1, 10**5, 2):
    if like(i):
        x_list[i] = 1

for i in range(Q):
    print(sum(x_list[l_r[i][0]: l_r[i][1]+1]))

Fixed submission:
import math
import sys
sys.setrecursionlimit(10000000)
Q = int(input())
l_r = [list(map(int, input().split())) for _ in range(Q)]

prime = []
def isprime(n):
    if n in prime:
        return True
    if n <= 1:
        return False
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    
    return True


def like(x):
    if isprime(x) and isprime((x+1)//2):
        return True
    
    return False

x_dict = {1:0}
def count_like(x):
    if x in x_dict:
        return x_dict[x]
    x_dict[x] = count_like(x-1) + like(x)
    return x_dict[x]

for i in range(Q):
    print(count_like(l_r[i][1]) - count_like(l_r[i][0]) + int(like(l_r[i][0])))
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)

Fixed submission:
N = input()

if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[1] == N[3]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
H, W = map(int, input().split())
edges = [[] for _ in range(10)]
for i in range(10):
    e_list = list(map(int, input().split()))
    for j in range(10):
        if j == i:
            continue
        edges[i].append([j, e_list[j]])
A = []
for i in range(H):
    A.append(list(map(int, input().split())))

def dijkstra(edges, num_v, start):
    dist = [float('inf')] * num_v
    dist[start] = 0
    q = []
    heapq.heappush(q, [0, start])

    while len(q) > 0:
        _, u = heapq.heappop(q)
        for edge in edges[u]:
            if dist[edge[0]] > dist[u] + edge[1]:
                dist[edge[0]] = dist[u] + edge[1]
                heapq.heappush(q, [dist[u] + edge[1], edge[0]])
    return dist
ans = 0
for a_line in A:
    for a in a_line:
        if a == -1 or a == 1:
            continue
        ans += dijkstra(edges, 10, a)[1]

print(ans)

Fixed submission:
import heapq
H, W = map(int, input().split())
edges = [[] for _ in range(10)]
for i in range(10):
    e_list = list(map(int, input().split()))
    for j in range(10):
        if j == i:
            continue
        edges[i].append([j, e_list[j]])
A = []
for i in range(H):
    A.append(list(map(int, input().split())))

def dijkstra(edges, num_v, start):
    dist = [float('inf')] * num_v
    dist[start] = 0
    q = []
    heapq.heappush(q, [0, start])

    while len(q) > 0:
        _, u = heapq.heappop(q)
        for edge in edges[u]:
            if dist[edge[0]] > dist[u] + edge[1]:
                dist[edge[0]] = dist[u] + edge[1]
                heapq.heappush(q, [dist[u] + edge[1], edge[0]])
    return dist
ans = 0
root_list = [0] * 10
for i in range(10):
    if i == 1:
        continue
    root_list[i] = dijkstra(edges, 10, i)[1]
for a_line in A:
    for a in a_line:
        if a == -1 or a == 1:
            continue
        ans += root_list[a]

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input(),split())
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)

Fixed submission:
A, B, C = map(int, input().split())
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(input().split())

edge_list =  []
selection = list(set(A)).sort()[::-1]

for i in selection:
    edge_list += i * (A.count(i) // 2)
    if len(edge_list) >= 2:
        break
edge_list.sort()

if len(edge_list) < 2:
    print(0)
else:
    print(int(edge_list[-1]) * int(edge_list[-2]))

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))

x = 0
y = 0
selection = sorted(list(set(A)))[::-1]
c = collections.Counter(A)
for i in selection:
    if c[i] >= 4:
        if x == 0:
            x = i
        if y == 0:
            y = i
    elif c[i] >= 2:
        if x == 0:
            x = i
        elif y == 0:
            y = i
    if x != 0 and y != 0:
        print(x * y)
        exit()

print(x * y)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans = (ans * T[i]) // math.gcd(ans, T[i])

print(ans)

Fixed submission:
import fractions
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans = (ans * T[i]) // fractions.gcd(ans, T[i])

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // math.gcd(ans, T[i])

print(ans)

Fixed submission:
import fractions
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans = (ans * T[i]) // fractions.gcd(ans, T[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(Graph, N, start):
    q = queue.Queue()
    dist = [-1] * N
    dist[start] = 0
    q.put(start)

    while not q.empty():
        v = q.get()
        for u in G[v]:
            if dist[u] != -1:
                continue
            dist[u] = dist[v] + 1
            q.put(u)

    return dist
if dfs(G, N, 0)[-1] > 2 or dfs(G, N, 0)[-1] == -1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Fixed submission:
import queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(Graph, N, start):
    q = queue.Queue()
    dist = [-1] * N
    dist[start] = 0
    q.put(start)

    while not q.empty():
        v = q.get()
        if dist[v] >1:
            continue
        for u in G[v]:
            if dist[u] != -1:
                continue
            dist[u] = dist[v] + 1
            q.put(u)

    return dist
if dfs(G, N, 0)[-1] > 2 or dfs(G, N, 0)[-1] == -1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
min = float('inf')
for i in range(1,N):
    sunuke = a[:i]
    kuma = a[i:]
    if abs(sum(sunuke) - sum(kuma)) < min:
        min = abs(sum(sunuke) - sum(kuma))
print(min)

Fixed submission:
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))

a = abs(2*np.cumsum(a) - a.sum())[:-1]

print(min(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []

for i in range(n):
    if i % 2 == n % 2:
        b.append(a[i])
    else:
        b.insert(0, a[i])
for i in range(n):
    print(b[i], end=' ')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
total = (n - 1) // 2
if n % 2 == 0:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[-total+div-1] = a[i]
        else:
            b[total-div] = a[i]
else:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[total - div] = a[i]
        else:
            b[-total+div] = a[i]

for i in range(n):
    print(b[i], end=' ')
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(lambda x: int(x) // 400, input().split()))
s_a = []
b_a = []

for i in range(N):
    if a[i] <= 7:
        s_a.append(a[i])
    else:
        b_a.append(a[i])

if len(s_a) == 0:
    min = 1
else:
    min = len(set(s_a))

if len(set(s_a)) + len(b_a) <= :
    max = len(set(s_a)) + len(b_a)
else:
    max = 7

print(min, max)

Fixed submission:
N = int(input())
a = list(map(lambda x: int(x) // 400, input().split()))
s_a = []
b_a = []

for i in range(N):
    if a[i] <= 7:
        s_a.append(a[i])
    else:
        b_a.append(a[i])

if len(s_a) == 0:
    min = 1
else:
    min = len(set(s_a))


max = len(set(s_a)) + len(b_a)


print(min, max)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
a_b = [list(map(input().split())) for i in range(N)]
a_b.sort()
index = 0

for i in range(N):
    index += a_b[i][1]
    if index >= K:
        print(a_b[i][0])
        exit()

Fixed submission:
N, K = map(int, input().split())
a_b = [list(map(int, input().split())) for i in range(N)]
a_b.sort()
index = 0

for i in range(N):
    index += a_b[i][1]
    if index >= K:
        print(a_b[i][0])
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
a_b = [list(input().split()) for i in range(N)]
big_array = []

for i in range(N):
    big_array += [a_b[i][0]] * int(a_b[i][1])

print(sorted(big_array)[K-1])


Fixed submission:
N, K = map(int, input().split())
a_b = [list(map(int, input().split())) for i in range(N)]
a_b.sort()
index = 0

for i in range(N):
    index += a_b[i][1]
    if index >= K:
        print(a_b[i][0])
        exit()
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
edges = []
for i in range(M):
    a, b, c = map(int, input().split())
    edges.append([a, b, -c])
def bellman_ford(edges, N):
    dist = [float('inf') for i in range(N)]
    dist[0] = 0
    for i in range(N-1):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
    negative = ['false'] * len(N)

    for i in range(N):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
                negative[edge[1] - 1] = True
            if negative[edge[0] - 1] == True:
                negative[edge[1] - 1] =True

    return 'inf' if negative[-1] else -dist[-1]

print(bellman_ford(edges, N))

Fixed submission:
N, M = map(int, input().split())
edges = []
for i in range(M):
    a, b, c = map(int, input().split())
    edges.append([a, b, -c])
def bellman_ford(edges, N):
    dist = [float('inf') for i in range(N)]
    dist[0] = 0
    for i in range(N-1):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
    negative = [False] * N

    for i in range(N):
        for edge in edges:
            if dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
                negative[edge[1] - 1] = True
            if negative[edge[0] - 1] == True:
                negative[edge[1] - 1] =True
    
    return 'inf' if negative[-1] else -dist[-1]

print(bellman_ford(edges, N))
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A % B == 0:
    if C == 0:
        print('YES')
    else:
        print('NO')
elif A > B:
    if C % (A % B) == 0 or (B - C) % (A % B) == 0:
        print('YES')
    else:
        print('NO')
else:
    if C % (B - A) == 0 or (B - C) % A == 0 or (B - C) % (B % A):
        print('YES')
    else:
        print('NO')

Fixed submission:
A, B, C = input().split()
print('YES' if A[-1]==B[0] and B[-1]==C[0] else 'NO')
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A % B == 0:
    if C == 0:
        print('YES')
    else:
        print('NO')
elif A > B:
    if C % (A % B) == 0 or (B - C) % (A % B) == 0:
        print('YES')
    else:
        print('NO')
else:
    if C % (B - A) == 0 or (B - C) % A == 0 or (B - C) % (B % A):
        print('YES')
    else:
        print('NO')

Fixed submission:
A, B, C = map(int, input().split())
C_list = []
if A >= B:
    num = A % B
    while num not in C_list:
        C_list.append(num)
        num += A % B
        if num >= B:
            num -= B
elif A < B:
    num = A
    while num not in C_list:
        C_list.append(num)
        num += A
        if num >= B:
            num -= B
print('YES' if C in C_list else 'NO')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A == B:
    if C == 0:
        print('YES')
    else:
        print('NO')
elif A > B:
    if C % (A % B) == 0 or (B - C) % (A % B) == 0:
        print('YES')
    else:
        print('NO')
else:
    if C % (B - A) == 0 or (B - C) % A == 0 or (B - C) % (B % A):
        print('YES')
    else:
        print('NO')

Fixed submission:
A, B, C = map(int, input().split())
C_list = []
if A >= B:
    num = A % B
    while num not in C_list:
        C_list.append(num)
        num += A % B
        if num >= B:
            num -= B
elif A < B:
    num = A
    while num not in C_list:
        C_list.append(num)
        num += A
        if num >= B:
            num -= B
print('YES' if C in C_list else 'NO')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A == B:
    if C == 0:
        print('YES')
    else:
        print('NO')
elif A > B:
    if C % (A % B) == 0 or (B - C) % (A % B) == 0:
        print('YES')
    else:
        print('NO')
else:
    if C % (A % B) == 0 or (B - C) % (B % A) == 0:
        print('YES')
    else:
        print('NO')

Fixed submission:
A, B, C = map(int, input().split())
C_list = []
if A >= B:
    num = A % B
    while num not in C_list:
        C_list.append(num)
        num += A % B
        if num >= B:
            num -= B
elif A < B:
    num = A
    while num not in C_list:
        C_list.append(num)
        num += A
        if num >= B:
            num -= B
print('YES' if C in C_list else 'NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
sum_ = 0
for i in range(n):
    if sum_ * (sum_+a[i]) <0 or i == 0:
        sum_ += a[i]
    elif sum_ > 0:
        count += sum_+a[i]+1
        a[i] = -sum_-1
        sum_ += a[i]
    elif sum_ < 0:
        count += abs(sum_+a[i])+1
        a[i] = -sum_+1
        sum_ += a[i]

print(count)

Fixed submission:
s1, s2, s3 = input().split()

ans = s1[0] + s2[0] + s3[0]

print(ans.upper())
Buggy python submission (verdict: Runtime Error):
O = input()
E = input()
ans = ''

for i in range(len(O)):
    ans += O[i]
    ans += E[i]

print(ans)

Fixed submission:
O = input()
E = input()
ans = ''

for i in range(len(O)):
    ans += O[i]
    if i != len(E):
        ans += E[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

ans = 0
loc = 0
while loc < X:
    ans += 1
    for i in range(ans):
        loc += 1
print(ans)

Fixed submission:
X = int(input())

ans, loc = 0, 0

while loc < X:
    ans += 1
    loc = ans/2 * (ans+1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
power = 1

for i in range(N):
    power *= (i+1)
print(power % (10**9+7))

Fixed submission:
import math
N = int(input())
power = math.factorial(N)
print(power % (10**9+7))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A==B:
    print("Draw")
elif A>B or A==1:
    print("Alice")
elif　A<B or B==1:
    print("Bob")

Fixed submission:
A, B = map(int, input().split())

if A==B:
    print("Draw")
elif (A>B and B != 1) or A==1:
    print("Alice")
else:
    print('Bob')

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A==B:
    print("Draw")
elif A>B or A==1:
    print("Alice")
elif:　A<B or B==1:
    print("Bob")

Fixed submission:
A, B = map(int, input().split())

if A==B:
    print("Draw")
elif (A>B and B != 1) or A==1:
    print("Alice")
else:
    print('Bob')
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
m_count = 0
m_str = []

for i in range(N):
    if S.count(S[i]) > m_count:
        m_str = [S[i]]
        m_count = S.count(S[i])
    elif S.count(S[i]) == m_count:
        m_str.append(S[i])

m_str = list(set(m_str))
m_str.sort()

print(m_str[i] for i in len(m_str))

Fixed submission:
A, _, B = input().split()
A, B = int(A), int(B)
print(A+B if _=='+' else A-B)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import fractions
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

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

MODp = 1000000007
K = 1
for i in range(N):
  K = lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K // l[i])%MODp)

Ans = Ans % MODp
print(Ans)

Fixed submission:
import math
import fractions
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

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

MODp = 1000000007
K = 1
for i in range(N):
  K = lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K // l[i]))

Ans = Ans % MODp
print(Ans)

Buggy python submission (verdict: Runtime Error):
import math
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N = int(input())
l = []
l = list(map(int, input().split()))

MODp = 1000000007
K = 1
for i in range(N):
  K = lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K / l[i])%MODp)

Ans = Ans % MODp
print(Ans)

Fixed submission:
import math
import fractions
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

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

MODp = 1000000007
K = 1
for i in range(N):
  K = lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K // l[i]))

Ans = Ans % MODp
print(Ans)

Buggy python submission (verdict: Runtime Error):
import math
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N = int(input())
l = []
l = list(map(int, input().split()))

MODp = 1000000007
K = 1
for i in range(N):
  K = math.lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K / l[i])%MODp)

Ans = Ans % MODp
print(Ans)

Fixed submission:
import math
import fractions
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

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

MODp = 1000000007
K = 1
for i in range(N):
  K = lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K // l[i]))

Ans = Ans % MODp
print(Ans)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
l = []
l = list(map(int, input().split()))

MODp = 1000000007
K = 1
for i in range(N):
  K = math.lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K / l[i])%MODp)

Ans = Ans % MODp
print(Ans)

Fixed submission:
import math
import fractions
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

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

MODp = 1000000007
K = 1
for i in range(N):
  K = lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K // l[i]))

Ans = Ans % MODp
print(Ans)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
l = []
for i in range(N):
  l = list(map(int, input().split()))

MODp = 1000000007
K = 1
for i in range(N):
  K = math.lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K / l[i])%MODp)

Ans = Ans % MODp
print(Ans)

Fixed submission:
import math
import fractions
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

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

MODp = 1000000007
K = 1
for i in range(N):
  K = lcm(K,l[i])

Ans = 0
for i in range(N):
  Ans += ((K // l[i]))

Ans = Ans % MODp
print(Ans)