#include using namespace std; #define int long long const int N = 4e5 + 10; int n, a[N], cnt[N], ans, sum; int in() { int k=0,f=1; char c=cin.get(); while(c<'0'||c>'9') { if(c=='-')f=-1; c=getchar(); } while(c>='0'&&c<='9')k=k*10+c-'0',c=cin.get(); return k*f; } void out(int x) { if(x<0)cout.put('-'),x=-x; if(x<10)cout.put(x+'0'); else out(x/10),cout.put(x%10+'0'); } signed main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen("mod.in", "r", stdin); // freopen("mod.out", "w", stdout); n = in(); for(int i = 1; i <= n; i++){ a[i] = in(); cnt[a[i]]++; ans += n * a[i]; } for(int i = 1; i <= 4e5; i++){ cnt[i] += cnt[i - 1]; } for(int i = 1; i <= 2e5; i++){ int ttt = cnt[i] - cnt[i - 1]; for(int j = 0; j * i <= 2e5; j++){ int c = 0; if(j * i - 1 >= 0){ c = cnt[(j + 1) * i - 1] - cnt[i * j - 1]; } else{ c = cnt[(j + 1) * i - 1]; } sum += c * ttt * i * j; } } out(ans - sum); return 0; }