#include void merge_sort(int n, int x[]) { static int y[200001] = {}; if (n <= 1) return; merge_sort(n / 2, &(x[0])); merge_sort((n + 1) / 2, &(x[n/2])); int i, p, q; for (i = 0, p = 0, q = n / 2; i < n; i++) { if (p >= n / 2) y[i] = x[q++]; else if (q >= n) y[i] = x[p++]; else y[i] = (x[p] < x[q])? x[p++]: x[q++]; } for (i = 0; i < n; i++) x[i] = y[i]; } int main() { int i, N, M = 200000, A[200001], a[400001] = {}; scanf("%d", &N); for (i = 0; i < N; i++) scanf("%d", &(A[i])); merge_sort(N, A); for (i = 0; i < N; i++) a[A[i]] = 1; int j, k, num[400001]; long long ans = 0, sum[400001]; for (i = 1, num[0] = 0, sum[0] = 0; i <= M; i++) { if (a[i] != 0) { num[i] = num[i-1] + 1; sum[i] = sum[i-1] + i; } else { num[i] = num[i-1]; sum[i] = sum[i-1]; } } for (; i <= M * 2; i++) { num[i] = num[i-1]; sum[i] = sum[i-1]; } for (i = 0; i < N; i++) { for (j = 1; j * A[i] + 1 <= M; j++) { ans += (long long)(num[(j+1)*A[i]-1] - num[j*A[i]]) * A[i] * (j + 1) - (sum[(j+1)*A[i]-1] - sum[j*A[i]]); if (a[(j+1)*A[i]] == 1) ans += A[i]; } } printf("%lld\n", ans); fflush(stdout); return 0; }