#include using namespace std; typedef long long ll; const ll MAX = 300000; ll b[MAX + 1]{}; ll c[MAX + 1]{}; int main() { int N; cin >> N; ll A[N]; ll sum = 0; set s; for (int i = 0; i < N; i++) { cin >> A[i]; b[A[i]]++; s.insert(A[i]); sum += A[i]; } for (int i = 1; i <= MAX; i++) { c[i] = c[i - 1] + b[i]; } ll ans = sum * N; //cout << ans << "\n"; for (ll i : s) { int t = i; if (i == 1) { ans -= b[1] * sum; continue; } //cout << "***********\n"; //cout << i << "\n"; for (ll k = 1; k < MAX; k++) { ll l = i * k - 1; ll r = min(MAX, i * (k + 1) - 1); if (l > 200005) break; //cout << l << " " << r << "\n"; //cout << c[r + 1] - c[l + 1] << " " << b[i * k] << "\n"; ll e = (c[r] - c[l]) * k * i * b[i]; ans -= e; // if (e < 0) { // cout << l << " " << r << "\n"; // cout << c[r] << " " << c[l] << "\n"; // cout << k << " aa\n"; // break; // } //cout << e << "\n"; } //cout << ans << "\n"; } cout << ans << "\n"; // for (int i = 0; i < 100; i++) { // cout << c[i] << "\n"; // } // cout << "\n"; // for (int i = 0; i < 10; i++) { // cout << c[i] << " "; // } return 0; }