#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

int main(){
    ios;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans=0;
   
    vector<ll> s(n+1);
    for(ll i=n;i>=1;i--){
        s[i-1]=s[i]+a[i-1];
    }
     rep(i,n){
        ans+=(n-1-i)*a[i]+s[i+1];
    }
    rep(i,n){
        for(ll j=1;j<=a[n-1]/a[i];j++){
            auto it=lower_bound(a.begin(),a.end(),j*a[i])-a.begin();
            ans-=a[i]*(n-it);
        }
    }
    cout << ans+s[0] << endl;
    return 0;
}