#include std::map history; long Operate(long e) { // std::cout << "Operate: " << e << std::endl; const auto it = history.find(e); if (history.end() == it) { std::vector divisors; divisors.push_back(e); for (long k = 2; (k*k) <= e; ++k) { if (0 == e % k) { divisors.push_back(k); divisors.push_back(e/k); } } long max = e+1; for (const auto& p : divisors) max = std::max(max, p*Operate(e/p) + 1); history[e] = max; // std::cout << "calculated" << max << std::endl; return max; } else { // std::cout << "from history" << it->second << std::endl; return it->second; } } long longestSequence(const std::vector& data) { long result = 0; for(const auto& e : data) result += Operate(e); return result; } int main() { int n; std::cin >> n; std::vector data(n); long int max = LONG_MIN; for(int i = 0; i < n; i++){ long int tmp; std::cin >> tmp; max = std::max(tmp, max); data[i] = tmp; } history[1] = 1; long result = longestSequence(data); std::cout << result << std::endl; return 0; }