#include using namespace std; using ll = long long; constexpr int N = 1000000; vector primes(N); vector marked(N + 1, false); void sieve(ll n) { n = (n - 2) / 2; for (ll i = 1; i <= n; i++) for (ll j = i; (i + j + 2*i*j) <= n; j++) marked[i + j + 2 * i * j] = true; int k = 0; primes[k++] = 2; for (int i = 1; i <= n; i++) if (marked[i] == false) primes[k++] = 2 * i + 1; primes.resize(k); } long longestSequence(const vector &a) { // Return the length of the longest possible sequence of moves. ll result = 0; for (ll e : a) { while (e > 1) { int i = 0; bool found = false; while(i < primes.size()) { if (e % primes[i] == 0) { result += e; e /= primes[i]; found = true; break; } ++i; } if (!found) { result += (e + 1); e = 0; } } result += e; } return result; } int main() { int n; cin >> n; sieve(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; }