#include using namespace std; int dp[1000000]; long maxDivide(long x) { if (x == 1) { return 1; } if (dp[x]) { return dp[x]; } long threshold = sqrt(x)*sqrt(x); long maxAns = x + 1; while (threshold > 1) { if (x % threshold == 0) { if (dp[x/threshold]) { maxAns = max(1 + threshold *dp[x/threshold], maxAns); } else { maxAns = max(1 + threshold * maxDivide(x/threshold), maxAns); } } threshold--; } dp[x] = maxAns; return maxAns; } long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long count = 0; for (auto each: a) { count += maxDivide(each); } return count; } 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; }