#include using namespace std; long helper(long cur, long num, unordered_map& mp){ if(mp.find(cur) != mp.end()) return mp[cur] * num; long next = 1; long best = 0; for(long i = sqrt(cur); i > 1; i--){ if(cur % i == 0){ next = i; long rest = cur / next; best = max(best, 1 + max(helper(next, rest, mp), helper(rest, next, mp))); } } if(next == 1) best = 1 + cur; mp[cur] = best; return best * num; } long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long ans = 0; unordered_map mp({{1, 1}}); for(auto n : a) ans += helper(n, 1, mp); return ans; } int main() { int n; cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long result = longestSequence(a); cout << result << endl; return 0; }