#include using namespace std; using ll=long long; using ld=long double; using P=pair; using V=vector; #define rep(i,n) for(int i=0;i> n; rep(i,n) cin >> a[i]; sort(a.begin(),a.end()); rep(i,n) b[i+1]=b[i]+a[i]; ll ans=0; rep(i,n-1) ans+=a[i]*(n-i-1); rep(i,n-1){ int l,r=i+1; for(ll j=1;a[i]*j<=a[n-1];j++){ l=r; r=min(n,src(a[i]*(j+1))); ans-=b[r]-b[l]-a[i]*(r-l)*j; } } cout << ans << endl; }