#include #define FOR(x, a, b) for (int x = a; x <= b; ++x) #define FOD(x, a, b) for (int x = a; x >= b; --x) #define REP(x, a, b) for (int x = a; x < b; ++x) #define DEBUG(X) { cout << #X << " = " << X << endl; } #define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; } #define PR0(A, n) { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; } using namespace std; const int BASE = (int)1e4; typedef long long LL; typedef pair II; typedef vector BigInt; vector Factor(LL n) { vector res; for (LL i = 2; i * i <= n; ++i) if (n % i == 0) { int d = 0; while (n % i == 0) { n /= i; ++d; } res.push_back(II(i, d)); } if (n != 1) res.push_back(II(n, 1)); return res; } void Fix(BigInt &A) { A.push_back(0); REP(i, 0, (int)A.size() - 1) { A[i + 1] += A[i] / BASE; A[i] %= BASE; if (A[i] < 0) { A[i] += BASE; A[i + 1]--; } } while (A.size() >= 2 && A.back() == 0) A.pop_back(); } void operator += (BigInt &A, BigInt B) { A.resize(max(A.size(), B.size())); REP(i, 0, B.size()) A[i] += B[i]; Fix(A); } BigInt operator + (BigInt A, const BigInt &B) { A += B; return A; } BigInt operator * (const BigInt &A, const BigInt &B) { BigInt C; C.resize(A.size() + B.size()); REP(i, 0, A.size()) REP(j, 0, B.size()) C[i + j] += A[i] * B[j]; Fix(C); return C; } BigInt Init(const string &S) { BigInt ans; ans.resize(S.size() / 4 + 2); REP(i, 0, S.size()) { int k = S.size() - i - 1; ans[k / 4] = ans[k / 4] * 10 + (S[i] - '0'); } Fix(ans); return ans; } BigInt Integer(LL n) { if (n < BASE) return BigInt(1, n); string S = ""; while (n) { S += (char)(n % 10 + '0'); n /= 10; } reverse(S.begin(), S.end()); return Init(S); } void Print(const BigInt &A) { printf("%d", A.back()); FOD(i, (int)A.size() - 2, 0) printf("%04d", A[i]); } int n; BigInt Compute(vector f) { if (f.size() == 1) { if (f[0].second == 1) return Integer(f[0].first + 1); else { f[0].second--; return Integer(1) + Integer(f[0].first) * Compute(f); } } else { II &last = f.back(); if (last.second == 1) { LL v = last.first; f.pop_back(); return Integer(1) + Integer(v) * Compute(f); } else { last.second--; return Integer(1) + Integer(last.first) * Compute(f); } } } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // LOCAL // ios_base::sync_with_stdio(false); //scanf("%d", &n); cin >> n; BigInt ans = Integer(0); FOR(i, 1, n) { LL v; cin >> v; //scanf("%lld", &v); if (v == 1) ans = ans + Integer(1); else { vector f = Factor(v); ans = ans + Compute(f); } } Print(ans); return 0; }