#include using namespace std; #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define PB push_back #define INF 2147483647 #define MP make_pair #define PII pair #define VS vector #define VI vector #define S size() #ifdef _SOUL_LOCAL #define print(___v) {cout<<"L:"<<__LINE__<<" [";if(___v.S)cout<<___v[0];FOR(___i,1,___v.S)cout<<","<<___v[___i];cout<<"]\n";} #define DEBUG(___x) cout<<"L:"<<__LINE__<<" "<<#___x<<" = ["<<___x<<"]"< string tos( T a ) { stringstream ss; string ret; ss << a; ss >> ret; return ret;} const int LM = 1e6+7; char mark[LM]; VI primes; vector::iterator it; void sieve() { clr(mark, 0); mark[1] = mark[0] = 1; primes.PB(2); for (int i = 4; i < LM; i += 2)mark[i] = 1; for (bint i = 3; i < LM; i += 2) { if (!mark[i]) { primes.PB(i); for (bint j = i * i; j < LM; j += (i*2))mark[j] = 1; } } } bint calc(bint v) { bint ans = 0; int l = primes.S; int pind = 0; while (true) { ans += v; if (v == 1)break; while (pind < l && (v % primes[pind]) != 0)pind++; if (pind < l)v /= primes[pind]; else { v /= v; } } return ans; } int main() { #ifdef _SOUL_LOCAL assert(freopen("in.txt", "r", stdin)); #endif int n; sieve(); while (cin >> n) { bint v; bint ans = 0; FOR (i,0,n) { cin >> v; ans += calc(v); } cout << ans << endl; } #ifdef _SOUL_LOCAL printf("T+[%.3f] sec\n", (double) clock() / CLOCKS_PER_SEC); #endif return 0; }