#include using namespace std; int cnt[200020], n, arr[200020]; long long ci[200020]; void add(int x, int v) { long long tmp = 1ll * x * v; for(; x <= 200000; x += x & -x) { ci[x] += tmp; } } long long queryi(int l) { long long ans = 0; for(; l; l -= l & -l) { ans += ci[l]; } return ans; } long long cal(int l, int r, int c) { return 1ll * c * (queryi(r) - queryi(l - 1)); } signed main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n; for(int i = 1; i <= n; i++) { cin >> arr[i]; cnt[arr[i]]++; } long long ans = 0; for(int i = 1; i <= 200000; i++) { if(!cnt[i]) { continue; } ans += 1ll * n * cnt[i] * i; add(i, cnt[i]); for(int j = 1; j <= i; ) { int r = i / (i / j); ans -= 1ll * cnt[i] * cal(j, r, i / j); j = r + 1; } } cout << ans << '\n'; return 0; }