#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vectorvl; typedef vectorvi; typedef vectorvb; typedef vectorvd; typedef vectorvc; typedef vectorvs; #define MP make_pair #define all(v) v.begin(),v.end() const ll mod = 1000000007; const ll OO = (ll)1e18; const int dx[] = { 0, 1, -1, 0 }; const int dy[] = { 1, 0, 0, -1 }; ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); } ll fast_power(double base, ll power){ if (power == 1) return base; if (power % 2 == 0) return fast_power((base*base), power / 2); else return(base*fast_power((base*base), power / 2)); } //#pragma warning (disable : 4996) void Qalbaz() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } mapmp; ll dfs(ll node) { if (node == 1) return 1; if (mp[node] != 0) return mp[node]; ll i, mx = -1; for (i = 1; i * i < node; i++) { if (node % i == 0 && i != 1) return mx = dfs(node / i) + node; } if (i * i == node) mx = dfs(node / i) + node; return mp[node] = mx == -1? node + 1 : mx; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; ll a, ans = 0; while (n--) { cin >> a; ans += dfs(a); } cout << ans << endl; return 0; }