// Program to print all prime factors # include # include #include #include #include using namespace std; vector getPrimes(long n, vector vec) { double sqrt_of_n = sqrt(n); for (int i = 2; i <= sqrt_of_n; i++) { if (n % i == 0) { return vec.push_back(i), getPrimes(n / i, vec); } } vec.push_back(n); return vec; } long longestSequence(vector a) { int size = a.size(); long total=0; vector temp1; for (int i = 0; i < size; i++) { vector factors = getPrimes(a[i], temp1); std::reverse(factors.begin(), factors.end()); long moves = 1; long currentmultiply = 1; if (a[i] != 1) { for (int j = 0; j < factors.size(); j++) { currentmultiply *= factors[j]; moves += currentmultiply; } } total += moves; } return total; // Return the length of the longest possible sequence of moves. } 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; }