#include using namespace std; long longestSequence(vector a) { int t=a.size(); long long total=0; while(t--) { long curr_tot=1; long n=a[t]; vector temp; //To store prime factors while (!(n&1)) { temp.push_back(2); n = n/2; } // n must be odd at this point. So we can skip // one element (Note i = i +2) for (int i = 3; i <= sqrt(n); i = i+2) { while (n%i == 0) { temp.push_back(i); n = n/i; } } if (n > 2) temp.push_back(n); total += curr_tot; while(temp.size() > 0) { curr_tot *= temp.back(); temp.pop_back(); total += curr_tot; } } return total; } 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; }