#include using namespace std; using ll = long long; using ld = long double; const int N = 2e5 + 1; int n; ll a[N]; ll cnt[N]; ll ans; int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for(int i = 1; i <= n; i ++){ cin >> a[i]; cnt[a[i]] ++; ans += a[i] * n; } for(int i = 1; i < N; i ++){ cnt[i] += cnt[i - 1]; } for(int mod = 1; mod < N; mod ++){ for(int k = 0; (k + 1) * mod - 1 < N; k ++){ ans -= (cnt[(k + 1) * mod - 1] - (k * mod - 1 >= 0 ? cnt[k * mod - 1] : 0)) * (cnt[mod] - cnt[mod - 1]) * (mod * k); } } cout << ans; return 0; } /*** 3 1 5 3 8 8 8 8 8 8 8 8 8 ***/