#include #include using namespace std; int pow(int a, int b){ if(b == 0){ return 1; } else if(a == 0){ return 0; } else { return a * pow(a,b-1); } } long longestSequence(vector a) { if(a.empty()){ return 0; } // Return the length of the longest possible sequence of moves. int primes[] = { 97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2}; int total = 0; for(int j = 0; j < a.size(); j++){ int value = 1; int multi = 1; int factors [25]; int num = a[j]; for(int i = 0; i < 25; i++){ factors[i] = 0; while((num % primes[i]) == 0){ factors[i] += 1; num /= primes[i]; } value += multi * primes[i] * (pow(primes[i],factors[i])-1)/(primes[i] -1); multi *= pow(primes[i],factors[i]); } total += value; } 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; }