#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n; vector cnt(200200,0), tot(200200,0), sum(200200,0); rep(i,n){ ll a; cin >> a; cnt[a]++, tot[a]++; sum[a] += a; } rep(i,MAX) tot[i+1] += tot[i], sum[i+1] += sum[i]; ll ans = 0; for(int i=1;i<=MAX;i++){ ans += (tot[MAX] - tot[i])*cnt[i] * i; for(int j=2;;j++){ int x = min(i*j-1, MAX), y = i*(j-1); ll z = sum[x]-sum[y] - (tot[x]-tot[y])*y; z *= cnt[i]; ans -= z; if(x==MAX) break; } } cout << ans << '\n'; return 0; }