//Copyright © 2017 Snehil Santhalia #include using namespace std; typedef long long ll; typedef long double ld; typedef vector vi; typedef vector vvi; typedef pair ii; typedef vector vii; typedef vector vvii; #define INF 1e18 #define loop(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++) #define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ ) #define mem(a, v) memset(a, v, sizeof a) #define pb push_back #define mp make_pair #define MOD 1000000007 #define MAX(a,b) (((a)>(b))?(a):(b)) #define MIN(a,b) (((a)<(b))?(a):(b)) #define left(x) x<<1 #define right(x) (x<<1)|1 #define PI acos(-1.0) #define EPS 1e-9 int T = 1, N; vi factors[1000505]; ll ans[1000505], no; bitset<1000505> bs; vi primes; void sieve(){ ll n=1000005; bs.set(); bs[0]=bs[1]=0; loop(i,2,n) if(bs[i]){ primes.pb(i); for(ll j=i;j<=n;j+=i) { bs[j]=0; factors[j].pb(i); } } } bool isPrime(ll N){ if(N<=1000005) return bs[N]; else { for(int i=0;i<(int)primes.size();i++) if(!(N%primes[i])) return false; return true; } } void solve(){ cin >> N; ll tot = 0, j; loop(i,1,N) { cin >> no; while(no > 1) { if(isPrime(no)) {tot += no+1; break;} for(j = 0; j<(int)primes.size(); j++) if(no % primes[j] == 0) { tot += no; no /= primes[j]; break; } } if(no == 1) tot++; } cout << tot << endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); //cin>>T; sieve(); while(T--){ solve(); } return 0; }