#include #define pb push_back #define mp make_pair #define ppp pair, int> #define pp pair #define fi first #define se second #define N 1000010 #define mod 1000000007 #define inf 1000000001 #define esp 1e-9 #define BASE 311097 typedef long long ll; using namespace std; int nt; ll n; ll dp[N]; ll go(ll n) { if (n == 1) return 1; ll ret = n + 1; for (int i = 2; i <= sqrt(n); i++) if (n % i == 0) { ret = max(ret, 1 + (n / i) * dp[i]); if (n / i < N) ret = max(ret, 1 + i * dp[n / i]); } return ret; } int main() { //freopen("in.in", "r", stdin); //freopen("ou.ou", "w", stdout); //cout << getmax(2) << "\n"; dp[1] = 1; for (int i = 2; i < N; i++) { dp[i] = max(dp[i], (ll)i + 1); for (int j = i + i; j < N; j += i) dp[j] = max(dp[j], 1 + (j / i) * dp[i]); } ios::sync_with_stdio(false); cin >> nt; ll ret = 0; while (nt--) { cin >> n; ret += go(n); // cout << go(n) << "\n"; } cout << ret << "\n"; /**/return 0; }