#include using namespace std; using ll = long long; const int MAXN = 2e5 + 25; int n; ll ans; int a[MAXN]; ll c[MAXN]; int cnt[MAXN]; 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]]++; } for(int i = 1; i <= 2e5; i++) { for(int j = i; j <= 2e5; j += i) { c[j] += 1LL * cnt[i] * i; } c[i] += c[i - 1]; } for(int i = 1; i <= n; i++) { ans += 1LL * a[i] * n - c[a[i]]; } cout << ans; return 0; }