#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include //#include //#include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define forn(i, n) for(int i = 0; i < int(n); i++) #define forn1(i, n) for(int i = 1; i <= int(n); i++) #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() #define mp make_pair #define pb push_back #define x first #define y second typedef long long li; typedef long double ld; typedef pair pt; const int INF = int(1e9); const li INF64 = li(1e18); const ld PI = acosl(ld(-1)); const ld EPS = 1e-9; template inline T sqr(const T& x) { return x * x; } template inline T abs(const T& x) { return x > 0 ? x : -x; } inline bool inside(int x, int y, int n, int m) { return x >= 0 && x < n && y >= 0 && y < m; } inline int rnd() { return abs(rand() ^ (rand() << 15)); } inline int rnd(int n) { assert(n > 0); return rnd() % n; } inline int rnd(int lf, int rg) { return lf + rnd(rg - lf + 1); } inline li rndLL() { return rnd() * 1LL * rnd() + rnd(); } const int dx[4] = { -1, 0, +1, 0 }; const int dy[4] = { 0, +1, 0, -1 }; const int dx8[8] = { -1, -1, 0, +1, +1, +1, 0, -1 }; const int dy8[8] = { 0, +1, +1, +1, 0, -1, -1, -1 }; const int N = int(222); int n; li a[N]; void gen() { } bool read() { if (!(cin >> n)) return false; forn(i, n) assert(cin >> a[i]); return true; } unordered_map dp; li divs[111111]; int szd; li calc(li n) { //cerr << "n == " << n << endl; if (n == 1) return n; if (dp.count(n)) return dp[n]; li res = n + 1; //cerr << "n == " << n << endl; //cerr << "divs == " << endl; //forn(i, szd) cerr << divs[i] << ' '; cerr << endl; for (int i = 1; i < szd && divs[i] <= n; i++) { li cnt = divs[i]; //cerr << "d[i] == " << cnt << endl; //assert(cnt != 1); if (n % cnt == 0) res = max(res, 1 + cnt * calc(n / cnt)); } return dp[n] = res; } /* 1 3 6 1 2 4 8 24 == 2 2 2 3 1 2 4 8 24 */ void solve() { li ans = 0; forn(i, n) { li x = a[i]; szd = 0; for (li d = 1; d * d <= x; d++) if (x % d == 0) { divs[szd++] = d; divs[szd++] = x / d; } sort(divs, divs + szd); szd = int(unique(divs, divs + szd) - divs); //forn(j, szd) cerr << divs[j] << ' '; cerr << endl; assert(szd <= 100000); ans += calc(a[i]); } cout << ans << endl; } //#undef _DEBUG int main() { #ifdef _DEBUG assert(freopen("777.txt", "rt", stdin)); assert(freopen("output.txt", "wt", stdout)); #endif cout << setprecision(10) << fixed; cerr << setprecision(10) << fixed; int T = 1; srand(int(time(NULL))); //assert(scanf("%d", &T) == 1); forn(i, T) { #ifdef _DEBUG cerr << "TEST == " << i << endl; #endif assert(read()); //cout << "Case #" << i + 1 << ": "; solve(); //if(i == 1) break; #ifdef _DEBUG cerr << "curTime == " << clock() << " ms" << endl; #endif } #ifdef _DEBUG cerr << "TIME == " << clock() << " ms" << endl; #endif return 0; }