#include using namespace std; vector primes; void sieve(){ bool p[1000009]={false}; for(int i =2;i<=1000000;i++){ if(!p[i]){ primes.push_back(i); for(int j = i;j<=1000000;j+=i){ p[j] = true; } } } } long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. sieve(); int sz = a.size(); long ans = a.size(); for(int i=0;i fac; for(auto& j:primes){ if(a[i]%j==0){ while(a[i]%j==0){ fac.push_back(j);a[i]/=j; } } } if(a[i]!=1) fac.push_back(a[i]); int sz2 = fac.size(); for(int j=sz2-1;j>=0;j--){ pr*=fac[j]; ans+=pr; } } return ans; } int main() { int n; cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long result = longestSequence(a); cout << result << endl; return 0; }