Problem:


Score : 500 points

Problem Statement

Given are N positive integers A_1,...,A_N.

Consider positive integers B_1, ..., B_N that satisfy the following condition.

Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds.

Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.

Since the answer can be enormous, print the sum modulo (10^9 +7).

Constraints

1 \leq N \leq 10^4

1 \leq A_i \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).

Sample Input 1

3
2 3 4

Sample Output 1

13

Let B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.

Sample Input 2

5
12 12 12 12 12

Sample Output 2

5

We can let all B_i be 1.

Sample Input 3

3
1000000 999999 999998

Sample Output 3

996989508

Print the sum modulo (10^9+7).



Sample input:
3
2 3 4


Sample output:
13

Submission status: Runtime Error

Solution code:
from math import gcd

EOF = False

def lcm(a, b):
    return a * b // gcd(a, b)

mod = int(1e9 + 7)

while True:
    try:
        n = int(input())
        a = list(map(int, input().split()))
    except:
        break

    l = a[0]
    for i in range(1, n):
        l = lcm(l, a[i])

    ans = 0
    for i in range(n):
        ans = (ans + l // a[i]) % mod
    print(ans)

    if not EOF:
        break

Submission status: Runtime Error

Solution code:


import numpy as np
from functools import reduce
#import math

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


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:


import numpy as np
#from functools import reduce
import math

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


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
from math import gcd

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

if N == 1:
    print(1)
    exit()

def saisho_ko_baisu(A,B):
    return A*B // gcd(A,B)
#     # A < B
#     x = A*B
#     r = B%A
#     while r!=0:
#         B = A
#         A = r
#         r = B%A
#     return x//A

A.sort(reverse = True)
tmp = saisho_ko_baisu(A[0], A[1])
res = tmp//A[0] + tmp//A[1]
for i in range(2,N):
    if tmp % A[i] != 0:
        new = saisho_ko_baisu(A[i], tmp)
        res *= new//tmp
        tmp = new
    res += tmp // A[i]

print(res % (10**9 + 7))

Submission status: Runtime Error

Solution code:
from math import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = int(1e9 + 7)

while True:
    try:
        n = int(input())
        a = list(map(int, input().split()))
    except:
        break

    l = a[0]
    for i in range(1, n):
        l = lcm(l, a[i])

    ans = 0
    for i in range(n):
        ans = (ans + l // a[i]) % mod
    print(ans)

Submission status: Runtime Error

Solution code:


import numpy as np
#from functools import reduce
import math

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


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
def func(x,y):
    return (x*y)//fractions.gcd(x,y)
AB = reduce(func, A, 1)
sumB = 0
for ii in range(N):
    sumB += AB/A[ii]
print(sumB%(10**9+7))

Submission status: Runtime Error

Solution code:


import numpy as np
from functools import reduce
import math

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


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))

from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

b = 0

for i in A:
    b += lcm_list(A)/i
print(int(b)%(10**9+7))

Submission status: Runtime Error

Solution code:
import math
def find(a):
    ans = a[0]
    for i in range(1,len(a)):
        ans = ((ans)//(math.gcd(ans,a[i])) * a[i])
    return ans            
	


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

lcm = find(a)
ans = 0
mod = pow(10,9)+7
for i in a:
	ans = ans + lcm//i
	
print(ans%mod)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))

from fractions import gcd

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

b = 0

for i in A:
    b += lcm_list(A)/i
print(int(b)%(10**9+7))

Submission status: Runtime Error

Solution code:
    from fractions import gcd
    from functools import reduce
     
    mod = 10 ** 9 + 7
     
    def lcm_base(x, y):
        return (x * y) // gcd(x, y)
     
    def lcm(numbers):
        return reduce(lcm_base, numbers, 1)
     
    # print('input >>')
    N = int(input())
    A = list(map(int,(input().split())))
     
    lcmn = lcm(A)
     
    ans = 0
    for i in range(len(A)):
        ans += lcmn // A[i]
     
    # print('-----output-----')
    print(int(ans%mod))

Submission status: Runtime Error

Solution code:


import numpy as np

import math

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


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm_list(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import fractions
N = int(input())
A = list(map(int, input().split()))
AB = 1
for i in A:
    AB = (AB*i)//fractions.gcd(AB,i)
sumB = 0
for ii in range(N):
    sumB += int(AB/A[ii])%(10**9+7)
print(int(sumB%(10**9+7)))

Submission status: Runtime Error

Solution code:
from fractions import gcd

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
lcm %= MOD
for i in A:
    ans += lcm//i
    ans %= MOD
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
from fractions import gcd
import numpy as np

MOD = 10**9+7

def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    A = np.array(a)

    lcm = np.lcm.reduce(A)
    B = lcm // A

    print(np.sum(B) % MOD)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
n = int(input())
a = [int(i) for i in input().split()]

b = 1
for i in a:
    b = b * i // gcd(b, i)

ans = 0
for i in a:
    ans += b // i
    ans %= 10**9+7

print(ans

Submission status: Runtime Error

Solution code:
import fractions
n = int(input())
mod = 10**9 + 7
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
b = []
for i in range(n):
    an = ans / a[i]
    b.append(an)

print(int(sum(b) % mod))

Submission status: Runtime Error

Solution code:


import numpy as np

import math

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


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



def lcm_list(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())

s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

l = lcm(a)
count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)

Submission status: Runtime Error

Solution code:

mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fractions.gcd(count, a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

kbs=lcm(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
mod=10 ** 9 + 7
ans=ans%mod
print(ans)

Submission status: Runtime Error

Solution code:
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashMap;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn gcd(a: u64, b: u64) -> u64{
    if b == 0{
        return a;
    }

    return gcd(b, a%b);
}

fn lcm(a: &HashMap<u64, u64>, b:  &HashMap<u64, u64>) -> HashMap<u64, u64>{
    let mut res  = a.clone();

    for (key, val) in b.iter(){
        let cur_val = res.entry(*key).or_insert(*val);
        if *cur_val < *val{
            *cur_val = *val;
        }
    }
    return res;
}

fn ext(x: u64) -> HashMap<u64, u64>{
    if x == 1{
        return HashMap::new();
    }
    let mut x = x;
    let mut hash = HashMap::new() ;
    for div in 2..(x as f64).sqrt().ceil() as u64+1{
        while x%div == 0{
            *hash.entry(div).or_insert(0) += 1;
            x /= div;
        }
    }
    *hash.entry(x).or_insert(0) += 1;
    return hash;

}

fn get_b(lcm_a: &HashMap<u64, u64>, a: &HashMap<u64, u64>) -> u64{
    let mut res = lcm_a.clone();

    for (key, value) in res.iter_mut(){
        if let Some(x) = a.get(key){
            *value -= x;
        }
        //*value -= a.get(key).unwrap();
    }

    let mut ans = 1;
    for (key, value) in res.iter(){
        for i in 0..*value{
            ans *= key;
            ans %= 1_000_000_007;
        }
    }

    return ans;
}

fn main(){
    let n: usize = read_as_vec::<usize>()[0];
    let a = read_as_vec::<u64>();
    let mut pa: Vec<HashMap<u64, u64>> = vec![];

    for &elem in &a{
        pa.push(ext(elem));
     }
    let mut lcm_a = pa[0].clone();

    for i in 0..pa.len(){
        lcm_a = lcm(&lcm_a, &pa[i]);
    }

    let mut ans = 0;
    for i in 0..pa.len(){
        let b = get_b(&lcm_a, &pa[i]);
        ans += b;
        ans %= 1_000_000_007;
    }

    println!("{}", ans);
}

Submission status: Runtime Error

Solution code:


import numpy as np

import math

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




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



def lcm_list(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=acinput()

s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
mod=10 ** 9 + 7
ans=ans%mod
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
lcm = A[0]
MOD = 10**9 + 7
for a in A:
    lcm = (lcm // gcd(lcm,a) * a)
res = 0
for a in A:
    res += lcm /a
print(res % MOD)

Submission status: Runtime Error

Solution code:

from functools import reduce
import numpy as np

import math

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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res



def lcm_list2(numbers):

    return reduce(lcm_base, numbers, 1)

N=int(input())
a=acinput()

s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fraction.gcd(count, a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fraction.gcd(x, y)
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
def GCD(a,b):
    if(b==0):
        return a
    else:
        aa = a%b
        return GCD(b,aa)
    #return b == 0 ? a:GCD(b,a%b)
n = int(input())
mod = 1e9 + 7
a = []
ans = 1

for i in range(1):
    a =list(input().split(' '))
    #a.append(x)
    #x = int(x)
for i in range(n):
    ans = int(a[i]) /GCD(ans,int(a[i]))*ans
sum = 0
for i in range(n):
    sum = sum+ans/int(a[i])
    sum = sum%mod
print("%d"%sum)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

Solution code:
from math import *
n = int(input())
a = list(map(int, input().split()))
#print(a)
b=[]
for i in range(n):
    #print(i)
    b.append(a[i])
for i in range(n):
    if i != 0:
        b[i]=int(b[i-1]/int(gcd(b[i-1],b[i])))*b[i]
lcm=b[n-1]
ans=0
for i in range(n):
    #print(a[i])
    ans=(ans+lcm/a[i])%(10**9+7)
print(int(ans))

Submission status: Runtime Error

Solution code:
import math

MOD = 1000000007
inv = [1] * 1001001

def LCM(a, b):
    gcd = math.gcd(a, b)
    return a * b // gcd

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

for i in range(2, 1001001):
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD

lcm = 1
for i in A:
    lcm = LCM(lcm, i)

ans = 0
for i in A:
    ans += lcm // i
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:

from functools import reduce
import numpy as np

import math

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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N=int(input())
a=acinput()

s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

Submission status: Runtime Error

Solution code:
import fractions
mod=10**9+7
n=int(input())
a=tuple(list(map(int,input().split())))

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

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:

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

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

l = lcm(a)
count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions
import sys
sys.setrecursionlimit(20000)

def lcm_base(a, b):
    return a * b / fractions.gcd(a, b)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = sorted(list(map(int, input().split())))
B = [0 for _ in range(N)]
mod = 10**9+7

ll = lcm_list(A)
ans = 0
for i in range(A):
    ans += ll // i
print(int(ans%mod))

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
import fractions
lmc=l[0]
for i in range(1,n):
   l[i]%=mod
   lmc=(lmc*l[i]//(fractions.gcd(lmc,l[i])))
ans=0
for i in range(n):
    ans += lcm*pow(l[i],mod-2,mod)
    ans %= mod
 print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

def gcdd(numbers):
    return reduce(gcd, numbers)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
a=list(map(int,input().split()))
# import numpy as np
lcmn = lcm_list(a)
ans = 0
for i in range(n):
    ans += (lcmn // a[i])  
print(ans% (10**9+7))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

Solution code:
def input():
    return sys.stdin.readline()[:-1]
from fractions import gcd
div = 10**9 + 7

sys.setrecursionlimit(10**7)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    sA = list(set(A))

    val = 1
    def lcm(a, b):
        ret = gcd(a, b)
        ret = a*b//ret
        return ret

    val = sA[0]
    for a in sA[1:]:
        val = lcm(val, a)

    B = [val//a for a in A]
    sumB = sum(B)
    sumB %= div

    print(sumB)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 

n = int(input())

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

lcm = inputs[0]
for i in inputs[1:]:
  lcm = int(lcm*i/gcd(lcm, i))

ans = 0;
lis = []
for i in inputs:
    ans = ans + int(int(lcm/i)%1000000007)
    ans = ans%1000000007;

print(ans)

Submission status: Runtime Error

Solution code:

from functools import reduce
import numpy as np
import sys
sys.setrecursionlimit(100000)

import math

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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N=int(input())
a=acinput()

s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fraction
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def lcm_base(x, y):
    return (x * y) // fraction.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

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

from fractions import gcd


def lcm(n, m):
    return n*m // gcd(n, m)

b = [0] * n
b[0], b[1] = a[1] // gcd(a[0], a[1]), a[0] // gcd(a[0], a[1])

for i in range(2, n):
    l = lcm(a[i-1] * b[i-1], a[i])
    b[i] = l // a[i]
    u = (a[i] * b[i]) // (a[i-1] * b[i-1])
    for j in range(i):
        b[j] *= u

ans = sum(b)
print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def lcm_base(x, y):
    return (x * y) // fraction.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

p = 10**9+7

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(A)

B = [lcm//i for i in A]

print(sum(B)%p)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

Solution code:
# Hello World program in Python
def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b) //gcd(a, b)
N = int(input())
A = list(map(int,input().split()))
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x)
for x in A:
    ans = (ans + l/x) % mod
print(ans)

Submission status: Runtime Error

Solution code:
import math


def main():
    N = int(input())
    A = list(map(int, input().split()))

    a = A[0]
    for i in range(1, N):
        a = a * A[i] // math.gcd(a, A[i])

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

    print(ans % (10 ** 9 + 7))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

fac = [1]
inv = [1]

for i in range(1, 10 ** 5) :
	fac.append(fac[-1] * i % MOD)
	inv.append(pow(fac[-1], MOD - 2, MOD))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
		
def lcm(a, b):
	return a * b // gcd(a, b)
		
		
a = 1
for i in range(N):
	a = lcm(A[i], a)

ans = 0
	
for i in range(N):
	ans += a * inv(A[i]) % MOD
	ans %= MOD
	
print(int(ans))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

def gcdd(numbers):
    return reduce(gcd, numbers)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
a=list(map(int,input().split()))
# import numpy as np
lcmn = lcm_list(a)
ans = 0
for i in range(n):
    ans += (lcmn // a[i])  % (10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

#べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い)
def modinv2(a,m):
    return pow(a,m-2,m)


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

A.sort()

inv = modinv2(A[0],P)
g = A[0]
invlist = []
seki = A[0]%P

for i in range(1,N):
    inv = (inv+modinv2(A[i],P))%P
    seki = seki*A[i]%P

g = gcd(A[0],A[1])
l = A[0]//g*A[1]
cc = modinv2(g,P)
for i in range(2,N):
    g = gcd(l,A[i])
    l = l//g*A[i]
    cc = cc*modinv2(g,P)%P

ans = (inv*seki%P)*cc%P

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

p = 10**9+7

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(A)

B = [lcm//i for i in A]

print(sum(B))

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    from fractions import gcd

    def lcd(x, y):
        g = gcd(x, y)
        return x * y // g

    n = int(input())
    a = tuple(map(int, input().split()))
    mod = 10 ** 9 + 7

    a.sort(reverse=True)
    l = 1
    for e in a:
        l = lcd(l, e)

    ans = 0
    for e in a:
        ans += (l // e) % mod
        ans %= mod

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

from math import gcd


def lcm(n, m):
    return n*m // gcd(n, m)

b = [0] * n
b[0], b[1] = a[1] // gcd(a[0], a[1]), a[0] // gcd(a[0], a[1])

for i in range(2, n):
    l = lcm(a[i-1] * b[i-1], a[i])
    b[i] = l // a[i]
    u = (a[i] * b[i]) // (a[i-1] * b[i-1])
    for j in range(i):
        b[j] *= u

ans = sum(b)
print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
from fractions import gcd
n = int(input())
a = sorted(map(int , input().split())))
l = a[0]
b = set(a)
for i in b:
    l = l * b[i] // gcd(l, b)
ans = float('INF')
mod = 10**9+7

tmp = 0
for i in a:
    tmp = (tmp + (l // i)) % mod
print(tmp)

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    if (x % y) == 0:
        return y
    else:
        return gcd(y, x % y)

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

N = int(input())

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

l = 1
for i in range(N):
    l = lcm(A[i], l)

ret = 0
for i in range(N):
    ret += l / A[i]

print(ret)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

P = 10**9 + 7
N = 1000000
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

_,p = [list(map(int, s.split())) for s in open(0)]
gcd_ = reduce(fractions.gcd, p)
lcm_ = 1
for q in p:
    lcm_ *= inv_t[q]
lcm_ *= inv_t[gcd_]
x = 1e9 + 7
ans = 0
for q in p:
    ans += int((lcm_/q)%x)
print(int(ans%x))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import fractions
from functools import reduce
n = int(input())
A = []
A = list(map(int, input().split()))
mod = 10**9 + 7
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
Z = lcm_base(A)
ans = sum(Z//a%mod for a in A)%mod
print(ans)

Submission status: Runtime Error

Solution code:
input = sys.stdin.readline

from functools import reduce
from fractions import gcd
import numpy as np

MOD = 10**9+7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    A = np.array(a)

    lcm = reduce(lcm_base, a, 1)
    B = lcm // A

    print(np.sum(B) % MOD)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

fac = [1]
inv = [1]

for i in range(1, N + 10) :
	fac.append(fac[-1] * i % MOD)
	inv.append(pow(fac[-1], MOD - 2, MOD))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
		
def lcm(a, b):
	return a * b // gcd(a, b)
		
		
a = 1
for i in range(N):
	a = lcm(A[i], a)

ans = 0
	
for i in range(N):
	ans += a * inv(A[i]) % MOD
	ans %= MOD
	
print(int(ans))

Submission status: Runtime Error

Solution code:

import fractions

N = int(input())

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

s = sum(A)

gcd = A[0]

for i in range(N):
    gcd = fractions.gcd(gcd,A[i])

ans = 0
for i in range(N):

    ans += (sum(A) - A[i])//gcd
    ans =%= 10**9+7

print (ans)

Submission status: Runtime Error

Solution code:
import fractions
mod = 1000000007
 
def add(a, b):
    return (a + b) % mod

n = int(input())
a = list(map(int,input().split()))
ans = a[0]
ans_ans = 0
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

import numpy as np
ary = np.array(a)
ary = ans / ary    

for j in range(0, n):
  ans_ans = add(ans_ans,ary[j])
  
print(int(ans_ans))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))

import math

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

b = 0

for i in A:
    b += lcm_list(A)/i
print(int(b)%(10**9+7))

Submission status: Runtime Error

Solution code:
import math


def main():
    N = int(input())
    A = list(map(int, input().split()))

    a = A[0]
    for i in range(1, N):
        a = a * A[i] // math.gcd(a, A[i])

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
b = []
for i in range(n):
    an = ans / a[i]
    b.append(int(an))
m = sum(b) % 10**9+7
print(m % (10**9  + 7))

Submission status: Runtime Error

Solution code:
import math
n = int(input())
m = 1000000007
l = list(map(int,input().split()))
a,v=1,1
for i in l:
    b = math.gcd(a,i)
    a = ((a*i)%m)*(pow(b,m-2,m))%m

ans=0
for i in range(n):
    ans+=a*pow(l[i],m-2,m)
    ans=ans%m
print(ans)