Buggy python submission (verdict: Time Limit Exceeded):
import fractions

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    MOD = 1000000007
    N = int(input())
    A = list(map(int, input().split()))
    lc = 1
    for i in A:
        lc = lcm(lc, i)
        ans = 0
    for i in A:
        ans += lc // i
    print(ans%MOD)

if __name__ == '__main__':
    main()

Fixed submission:
import fractions

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    prev_lc = 1
    ans = 0
    for i in A:
        lc = lcm(prev_lc, i)
        ans = ans * (lc // prev_lc) + lc // i
        prev_lc = lc
    print(ans % 1000000007)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

MOD = 1000000007

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    lc = 1
    for i in A:
        lc = lcm(lc, i)
        ans = 0
    for i in A:
        ans += lc // i
    print(ans%MOD)

if __name__ == '__main__':
    main()

Fixed submission:
import fractions

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    prev_lc = 1
    ans = 0
    for i in A:
        lc = lcm(prev_lc, i)
        ans = ans * (lc // prev_lc) + lc // i
        prev_lc = lc
    print(ans % 1000000007)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

MOD = 1000000007

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

N = int(input())
A = [int(x) for x in input().split()]
lc = 1
for i in A:
    lc = lcm(lc, i)
ans = 0
for i in A:
    ans = (ans + lc // i) % MOD
print(ans)

Fixed submission:
import fractions

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    prev_lc = 1
    ans = 0
    for i in A:
        lc = lcm(prev_lc, i)
        ans = ans * (lc // prev_lc) + lc // i
        prev_lc = lc
    print(ans % 1000000007)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

MOD = 1000000007

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

N = int(input())
A = [int(x) for x in input().split()]
lc = 1
for i in A:
    lc = lcm(lc, i)
ans = 0
for i in A:
    ans = (ans + lc // i) % MOD
print(ans)

Fixed submission:
import fractions

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    prev_lc = 1
    ans = 0
    for i in A:
        lc = lcm(prev_lc, i)
        ans = ans * (lc // prev_lc) + lc // i
        prev_lc = lc
    print(ans % 1000000007)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math

MOD = 1000000007

def lcm(x, y):
    return x * y // math.gcd(x, y)

N = int(input())
A = [int(x) for x in input().split()]
lc = 1
for i in A:
    lc = lcm(lc, i)
ans = 0
for i in A:
    ans = (ans + lc // i) % MOD
print(ans)

Fixed submission:
import fractions

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    prev_lc = 1
    ans = 0
    for i in A:
        lc = lcm(prev_lc, i)
        ans = ans * (lc // prev_lc) + lc // i
        prev_lc = lc
    print(ans % 1000000007)

if __name__ == '__main__':
    main()