#include using namespace std; long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long result = 0; for (int i = 0; i < a.size(); i++) { result += a[i]; while (a[i] % 2 == 0) { a[i] = a[i] / 2; result += a[i]; } // n must be odd at this point. So we can skip // one element (Note i = i +2) for (int j= 3; j <= sqrt(a[i]); j = j + 2) { // While i divides n, print i and divide n while (a[i] %j == 0) { a[i] = a[i] / j; result += a[i]; } } if (a[i] > 2) result += 1; } 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; }