#include using namespace std; using ll = long long; vector> Enum_floor(ll n) { vector> ret; ll l = 1; while(l <= n) { ll q = n / l, r = n / q + 1; ret.push_back({l, r, q}); l = r; } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; vector A(N), c(200001, 0); ll ans = 0; for(auto &i : A) { cin >> i; ans += i * N; c[i] += i; } for(ll i = 0; i < 200000; i++) { c[i + 1] += c[i]; } for(auto &i : A) { for(auto &[l, r, q] : Enum_floor(i)) { ans -= (c[--r] - c[--l]) * q; } } cout << ans << "\n"; }