#include using namespace std; const int maxn = 102; int n; int64_t a[maxn]; vector > p; map f; void fact(int64_t a) { for (int64_t i=2; i*i<=a; ++i) { if (a%i==0) { int64_t tmp = 1; while (a%i==0) { tmp *= i; a /= i; } p.push_back(make_pair(i, tmp)); return fact(a); } } if (a>1) p.push_back(make_pair(a, a)); } int64_t dp(vector > p) { int64_t res = 0, tmp = 1; for (int i=0; i<(int)p.size(); ++i) tmp *= p[i].second; if (f.count(tmp)) return f[tmp]; for (int i=0; i<(int)p.size(); ++i) { if (p[i].second>=p[i].first) { p[i].second /= p[i].first; res = max(res, dp(p)); p[i].second *= p[i].first; } } return f[tmp] = res + tmp; } int64_t LongestSequence(int _n, int64_t _a[]) { int64_t res = 0; for (int i=1; i<=n; ++i) { if (a[i]!=1) { p.clear(); f.clear(); fact(a[i]); res += dp(p); } else ++res; } return res; } int main() { //freopen("chocolate.inp", "r", stdin); ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=1; i<=n; ++i) cin >> a[i]; cout << LongestSequence(n, a); }