#include <bits/stdc++.h> using namespace std; typedef long long LL; map<LL, LL> mp; int cr[1000005]; vector<LL> primes; void ciur() { int N = int(1e6); for(int i = 1; i <= N; i++) cr[i] = i; for(int i = 2; i * i <= N; i++) if(cr[i] == i) for(int j = i * i; j <= N; j += i) cr[j] = i; for(int i = 2; i <= N; i++) if(cr[i] == i) primes.push_back(i); } LL solve(LL x) { LL ans = x; vector<LL> fct; for(auto f: primes) { if(1LL * f * f > x) break; while(x % f == 0) { fct.push_back(f); x /= f; } } if(x != 1) fct.push_back(x); LL tms = 1; reverse(fct.begin(), fct.end()); for(auto f: fct) { ans += tms; tms *= f; } return ans; } LL longestSequence(vector <LL> a) { ciur(); // Return the length of the longest possible sequence of moves. mp[1] = 1; LL ans = 0; for(auto x: a) { ans += solve(x); } return ans; } int main() { int n; cin >> n; vector<LL> a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } LL result = longestSequence(a); cout << result << endl; return 0; }