#include using namespace std; typedef long long ll; typedef vector vi; bitset<10000005> bs; vi primes; void sieve() { bs.set(); bs[0] = bs[1] = false; for(ll i = 2; i < 10000005; i++) if(bs[i]) { for(ll j = i * i; j < 10000005; j += i) bs[j] = false; primes.push_back(i); } } bool isPrime(ll n) { if(n < 10000005) return bs[n]; for(int i = 0; i < (int)primes.size(); i++) { ll p = primes[i]; if(n % p == 0) return false; if(p * p > n) return true; } return true; } ll solve(ll x) { if(x == 1) return 1; else if(isPrime(x)) return x + 1; else if(x % 2 == 0) return x + solve(x/2); else { for(ll i = 2; i * i <= x; i++) if(x % i == 0) return x + solve(x / i); return 0; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); sieve(); ll n,x,ans; while(cin >> n) { ans = 0; for(int i = 0; i < n; i++) { cin >> x; ans += solve(x); } cout << ans << '\n'; } return 0; }