#include using namespace std; typedef long long LL; #define FOR(i, x, y) for (decay::type i = (x), _##i = (y); i < _##i; ++i) #define FORD(i, x, y) for (decay::type i = (x), _##i = (y); i > _##i; --i) #ifdef zerol #define dbg(args...) do { cout << "\033[32;1m" << #args<< " -> "; err(args); } while (0) #else #define dbg(...) #endif void err() { cout << "\033[39;0m" << endl; } template void err(T a, Args... args) { cout << a << ' '; err(args...); } // ----------------------------------------------------------------------------- map mp; LL go(LL x) { if (x == 1) return 1; auto it = mp.find(x); if (it != mp.end()) return it->second; LL ret = x; LL t = int(sqrt(x + 0.5)); FOR (i, 2, t + 1) if (x % i == 0) ret = max(ret, max(go(i) * (x / i), go(x / i) * i)); return mp[x] = ret + 1; } int main() { LL ans = 0, n, t; cin >> n; FOR (_, 0, n) { cin >> t; ans += go(t); } cout << ans << endl; }