#include using namespace std; map sol; long solution(long x) { if (sol[x]) return sol[x]; vector > factor; long origX = x; for (int i = 2; i <= x; i++) { if (x % i) continue; factor.push_back(make_pair(i, 0)); while (x % i == 0) { factor.back().second++; x = x / i; } } long result = 0, temp = 1; for (int i = factor.size()-1; i>=0; i--) for (int j = 0; j < factor[i].second; j++) { result += temp; temp *= factor[i].first; } result += temp; return sol[origX] = result; } long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long result = 0; for (int i = 0; i < a.size(); i++) result += solution(a[i]); return result; } 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; }