#include using namespace std; long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long i, j; long Result = 0; for(i = 0; i < a.size(); i++) { int Sqrt = sqrt(a[i]); long Temp = a[i]; Result += a[i]; vector Factor; for(j = 2; j <= Sqrt; j++) { while((Temp % j) == 0) { Factor.push_back(j); Temp /= j; } } if(Temp > 1) { Factor.push_back(Temp); } sort(Factor.begin(), Factor.end()); Temp = a[i]; for(j = Factor.size() - 1; j >= 0; j--) { Result += (a[i] / Temp); Temp /= Factor[j]; //cout << Temp << " " << Factor[j] << endl; } //cout << Result << endl; //if(Temp > 1) //{ // Result += (a[i] / Temp); //} } return Result; } 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; }