#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("YES");}else{puts("NO");} #define MAX_N 200005 ll f[MAX_N]; ll sum[MAX_N], cnt[MAX_N]; int main() { int n; cin >> n; int a[n] = {}; rep(i,n){ cin >> a[i]; f[a[i]]++; } srep(i,1,MAX_N){ sum[i] = sum[i-1] + f[i] * i; cnt[i] = cnt[i-1] + f[i]; } ll ans = 0; srep(i,1,200001){ ans += sum[i-1] * f[i]; srep(j,1,MAX_N){ int ii = i * j; int k = i * (j+1) - 1; if(ii > 200000)break; if(k >= MAX_N) k = MAX_N - 1; ll tmp = sum[k] - sum[ii-1] - (cnt[k]-cnt[ii-1]) * j * i; // if(tmp > 0) cout << i << ' ' << j << ' ' << tmp << endl; ans += tmp * f[i]; } } cout << ans << endl; return 0; }