#include using namespace std; typedef long long ll; const int maxn = 1000000; unordered_map mem, mem_glob; vector primes; ll eat(ll stick) { if (stick == 1) return 1; if (mem[stick]) return mem[stick]; int res = 0; for (ll p : primes) { if (p > sqrt(stick)) break; if (stick%p == 0) return mem[stick] = stick + eat(stick/p); } return mem[stick] = stick+1; } ll longestSequence(unordered_map a) { ll res = 0; for (auto stick : a) { res += stick.second*eat(stick.first); } return res; } int main() { int n; cin >> n; unordered_map a; ll temp; for(int a_i = 0; a_i < n; a_i++){ cin >> temp; a[temp]++; } bool used[maxn]; fill(used, used + maxn, 0); for (ll i = 2; i < maxn; i++) if (!used[i]) { primes.push_back(i); for (int j = i; j < maxn; j += i) used[j] = 0; } ll result = longestSequence(a); cout << result << endl; return 0; }