#include using namespace std; typedef long long ll; int n; ll a[111]; bitset<1111111> IsPrime; vector Primes; // Generates prime numbers in range [0..upperbound] void Sieve(long upperbound) { IsPrime.set(); IsPrime[0] = IsPrime[1] = false; for (long long i = 2; i <= upperbound; i++) { if (IsPrime[i]) { Primes.push_back(i); for (long long j = i*i; j <= upperbound; j = j + i) { IsPrime[j] = false; } } } } void Input() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%lld", &a[i]); } void Solve() { ll sol = 0; Sieve(999999); for (int i = 0; i < n; i++) { vector v; ll tmpVal = a[i]; for (auto x : Primes) { while (tmpVal % x == 0) { v.push_back(x); tmpVal /= x; } } if (tmpVal > 1) v.push_back(tmpVal); if (v.size() == 0) v.push_back(a[i]); sort(v.begin(), v.end()); ll sum = 0, prod = 1; if (a[i] > 1) sum = 1; while (v.size()) { prod *= v.back(); sum += prod; v.pop_back(); } sol += sum; } cout << sol << endl; } int main() { Input(); Solve(); return 0; }