#include using namespace std; using LL = long long; const int N = 2e5 + 5, MAXN = 2e5; int n, a[N], vis[N]; LL sum[N], cnt[N], ans, now; int main(){ ios::sync_with_stdio(0), cin.tie(0); cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; cnt[a[i]] += a[i]; vis[a[i]]++; } for(int i = 0; i <= MAXN; ++i){ sum[i] = sum[i - 1] + cnt[i]; } for(int i = 0; i <= MAXN; ++i){ now = 0; for(int l = 1, r; l <= i; l = r + 1){ r = i / (i / l); now += 1ll * i / l * (sum[r] - sum[l - 1]); } ans += (1ll * n * i - now) * vis[i]; } cout << ans; return 0; } /* a[i] - (a[i] / a[j]) * a[j]; */