using
System;
using
System.Collections.Generic;
class
GFG {
static
long
mod = (
int
)(1e9 + 7);
static
int
size = (
int
)(1e6 + 100);
static
long
sub(
long
a,
long
b)
{
return
(mod + a % mod - b % mod) % mod;
}
static
long
mul(
long
a,
long
b)
{
return
(a % mod * b % mod) % mod;
}
static
long
power(
long
x,
long
y)
{
long
res = 1;
for
(res = 1; y > 0; x = (x * x) % mod, y >>= 1) {
if
((y & 1) == 1) {
res = (res * x) % mod;
}
}
return
res;
}
static
long
inverse(
long
a)
{
return
power(a, mod - 2);
}
static
int
[] spf =
new
int
[size];
static
void
sieve()
{
for
(
int
i = 1; i < size; i += 2)
spf[i] = i;
for
(
int
i = 2; i < size; i += 2)
spf[i] = 2;
for
(
int
i = 3; i * i < size; i += 2)
if
(spf[i] == i)
for
(
int
j = i * i; j < size; j += i)
spf[j] = i;
}
static
long
sumof_factors(
int
[] a,
int
n)
{
for
(
int
i = 0; i < n; i++)
if
(a[i] == 0)
return
0;
long
ans = 1;
Dictionary<
int
,
int
> count
=
new
Dictionary<
int
,
int
>();
for
(
int
i = 0; i < a.Length; i++) {
while
(a[i] > 1) {
int
temp = 0;
if
(count.ContainsKey(spf[a[i]]))
temp = count[spf[a[i]]];
count[spf[a[i]]] = temp + 1;
a[i] /= spf[a[i]];
}
}
foreach
(KeyValuePair<
int
,
int
> i
in
count)
{
long
num1 = sub(power(i.Key, i.Value + 1), 1);
long
num2 = inverse(i.Key - 1);
ans = mul(ans, mul(num1, num2));
}
return
ans;
}
public
static
void
Main(
string
[] args)
{
sieve();
int
n = 5;
int
[] a = { 1, 3, 2, 5, 4 };
Console.WriteLine(sumof_factors(a, n));
}
}