#include #include using namespace std; const int MAX = 200005; bool present[MAX]; int cnt[MAX]; long long sum_a[MAX]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; present[A[i]] = true; } cnt[0] = 0; sum_a[0] = 0; for (int x = 1; x < MAX; ++x) { cnt[x] = cnt[x-1] + (present[x] ? 1 : 0); sum_a[x] = sum_a[x-1] + (present[x] ? x : 0); } long long S1 = 0; for (int x : A) { S1 += (long long)x * (N - cnt[x]); } long long S2 = 0; for (int b : A) { long long sum_q = 0; int l = 1; while (l < b) { int q = b / l; int r = b / q; if (r >= b) r = b - 1; sum_q += (long long)q * (sum_a[r] - sum_a[l-1]); l = r + 1; } long long contrib = (long long)cnt[b-1] * b - sum_q; S2 += contrib; } cout << S1 - S2 << '\n'; return 0; }