#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 << 1]; ll ans; int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); freopen("mod.in", "r", stdin); freopen("mod.out", "w", stdout); 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 << 1); i ++){ cnt[i] += cnt[i - 1]; } for(int mod = 1; mod < N; mod ++){ for(int k = 0; k * mod < 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 ***/