#include using namespace std; map dp ; long solve(long n) { if(dp.count(n)) return dp[n] ; long &res = dp[n] ; res = 0 ; pair which ; if(n == 1) return res = 1 ; for(long d = 2 ; 1LL * d * d <= n ; ++d) { if(n % d == 0) { long len = d ; long cnt = n/d ; if(1 + solve(len) * cnt > res) { res = 1 + solve(len) * cnt ; which = {len,cnt} ; } if(d * d != n) { len = n/d ; cnt = d ; if(1 + solve(len) * cnt > res) { res = 1 + solve(len) * cnt ; which = {len,cnt} ; } } } } if(1 + solve(1) * n > res) { res = 1 + n * solve(1) ; which = {1,n} ; } cout << n << " " << res << " " << which.first << " " << which.second << endl ; return res ; } long Solve(long n) { if(dp.count(n)) return dp[n] ; if(n == 1) return 1 ; long &res = dp[n] ; res = 0 ; long temp = n ; long bigPrime = 0 ; for(long d = 2 ; d * d <= n ; ++d) { if(n % d == 0) { while(n % d == 0) n /= d ; bigPrime = max(bigPrime , d) ; } } if(n > 1) bigPrime = max(bigPrime,n) ; return res = 1 + Solve(temp/bigPrime) * bigPrime ; } long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long res = 0 ; for(auto it : a) res += Solve(it) ; return res ; } int main() { //freopen("input.txt","r",stdin); int n; cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long result = longestSequence(a); cout << result << endl; return 0; }