#include #define ll long long int using namespace std; map m; vector factorize(ll n) { vector res; for(ll i = 2; i * i <= n; ++i) { while (n % i == 0) { res.push_back(i); n /= i; } } if (n != 1) { res.push_back(n); } vector s; ll last = 0; for(int i = 0; i < res.size(); i++) { if(res[i] != last) { s.push_back(res[i]); last = res[i]; } } return s; } ll getAns(ll n) { if(n == 1){ m[n] = 1; return m[n]; } if(m.find(n) != m.end()) { return m[n]; } vector s = factorize(n); ll ans = 0; if(s[0] == n) { m[n] = n + 1; return m[n]; } for(int i = 0; i < s.size(); i++) { ans = max(ans, s[i] * getAns(n / s[i])); } m[n] = ans + 1; return m[n]; } int main() { ll n, ans = 0; cin >> n; for(int i = 0; i < n; i++) { ll x; cin >> x; ans = ans + getAns(x); } cout << ans << endl; return 0; }