/* RE/WA expected */ #include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int a[n]; int num_sum[200001] = { 0 }; for (int i = 0; i < n; i++) a[i] = ri(), num_sum[a[i]]++; int64_t sum = std::accumulate(a, a + n, 0LL); for (int i = 0; i < 200000; i++) num_sum[i + 1] += num_sum[i]; int64_t cache[400]; for (int i = 0; i < 400; i++) cache[i] = -1; int64_t res = 0; for (int i = 0; i < n; i++) { if (a[i] < 400) { if (cache[a[i]] == -1) { cache[a[i]] = 0; for (int j = 0; j < n; j++) cache[a[i]] += a[j] % a[i]; } res += cache[a[i]]; } else { res += sum; for (int j = 0; j <= 200000 / a[i]; j++) { int num = num_sum[(j + 1) * a[i] - 1]; if (j) num -= num_sum[j * a[i] - 1]; res -= (int64_t) a[i] * j * num; } } } std::cout << res << std::endl; return 0; }