#include #include #include #include #include using namespace std; long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long ans = 0; for (int i = 0; i<(int)a.size(); i++) { long sub_ans = 1; long m = a[i]; while (m > 1) { sub_ans += m; if (m % 2 == 0) m /= 2; else { bool found = false; for (int j = 3; j <= sqrt(m); j += 2) { if (m %j == 0) { found = true; m /= j; break; } } if (!found) m = 1; } } ans += sub_ans; } 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; }