#include using namespace std; using VI = vector; using VVI = vector; using PII = pair; using LL = long long; using VL = vector; using VVL = vector; using PLL = pair; using VS = vector; #define ALL(a) begin((a)),end((a)) #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(a) int((a).size()) #define SORT(c) sort(ALL((c))) #define RSORT(c) sort(RALL((c))) #define UNIQ(c) (c).erase(unique(ALL((c))), end((c))) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define FF first #define SS second template istream& operator>>(istream& is, pair& p){ return is >> p.FF >> p.SS; } template ostream& operator<<(ostream& os, const pair& p){ return os << p.FF << " " << p.SS; } template void maxi(T& x, T y){ if(x < y) x = y; } template void mini(T& x, T y){ if(x > y) x = y; } const double EPS = 1e-10; const double PI = acos(-1.0); const LL MOD = 1e9+7; const LL INF = 1e18; unordered_map memo; const int MAX = 1000100; bool isp[MAX]; VL ps; LL solve(LL x){ if(x == 1) return 1; if(memo.count(x)) return memo[x]; LL& res = memo[x]; res = x+1; LL tmp = x; for(int i=0;i1;++i){ LL p = ps[i]; if(tmp % p != 0) continue; while(tmp % p == 0) tmp /= p; if(x != p){ maxi(res, solve(p) * (x/p) + 1); maxi(res, solve(x/p) * p + 1); } } if(tmp > 1 && x != tmp){ maxi(res, solve(tmp) * (x/tmp) + 1); maxi(res, solve(x/tmp) * tmp + 1); } return res; } int main(){ cin.tie(0); ios_base::sync_with_stdio(false); fill(isp, isp+MAX, true); isp[0] = isp[1] = false; for(int i=2;i> N; LL ans = 0; REP(i,N){ LL x; cin >> x; ans += solve(x); } cout << ans << endl; return 0; }