//CuongTV #include #define FOR(i, a, b) for(int i = a; i <= b; ++i) #define FORD(i, a, b) for(int i = a; i >= b; --i) #define ll long long #define ii pair #define pb push_back #define mp make_pair #define MAXVAL 100000 #define MAXN 1000001 //Declare global variables using namespace std; bool sieve[MAXVAL + 1]; map minPrime; vector prime; int n; ll a[MAXN]; map f; void setup(){ cin >> n; FOR(i, 1, n) cin >> a[i]; FOR(i, 2, MAXVAL){ if(!sieve[i]){ prime.pb(i); for(int t = i * 2; t <= MAXVAL; t += i) sieve[t] = true; } } } ll getMinDiv(ll c){ if(minPrime.find(c) != minPrime.end()) return minPrime[c]; for(ll t:prime){ if(t > c) break; if(c % t == 0) return minPrime[c] = t; } return minPrime[c] = c; } ll cal(ll x){ if(f.find(x) != f.end()) return f[x]; ll t = x; ll res = x; while(x != 1){ x = x / getMinDiv(x); res += x; } return f[t] = res; } void process(){ ll res = 0; f[1] = 1; FOR(i, 1, n) res += cal(a[i]); cout << res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); setup(); process(); return 0; }