#include #include #include #include #include #include using namespace std; vector primes; void calcprimes(){ const long long MAX = 1100000; bool mark[MAX] = {}; for (long long trial=2; trial < MAX; trial++) { if (!mark[trial]) primes.push_back(trial); for (long long i = 2 * trial; i < MAX; i+=trial) mark[i] = true; } } unordered_map seen; long long solvediv(long long n, const vector & divs){ if(seen.find(n) != seen.end()){ return seen[n]; } if(n == 1){ return 1; } long long ret = 0; for(auto a : divs){ if(n % a == 0){ ret = max(a * solvediv(n / a, divs) + 1, ret); } } seen[n] = ret; return ret; } long long solve(long long n){ if(n == 1){ return 1; } vector divs; long long cp = n; long long i = 0; while(cp != 1){ if(cp % primes[i] == 0){ divs.push_back(primes[i]); } while(cp % primes[i] == 0){ cp /= primes[i]; } i++; if(i == primes.size()){ break; } } if(i == primes.size()){ divs.push_back(cp); } long long ret; ret = solvediv(n, divs); return ret; } int main() { int n; cin >> n; calcprimes(); vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } long long ret = 0; for(int i = 0; i < n; i ++){ ret += solve(a[i]); } cout << ret << endl; return 0; }