#include int ri() { int n; scanf("%d", &n); return n; } int n; int a[200000]; int read_uint() { int res = 0; for (int i = 0; ; i++) { int c = getchar(); if (c < '0' || c > '9') { assert(i); ungetc(c, stdin); break; } res *= 10; res += c - '0'; } return res; } void expect_nl() { int lb = getchar(); if (lb == '\r') lb = getchar(); assert(lb == '\n'); } void input() { n = read_uint(); expect_nl(); for (int i = 0; i < n; i++) { a[i] = read_uint(); if (i + 1 < n) assert(getchar() == ' '); } int c = getchar(); if (c == '\r') assert(getchar() == '\n'); assert(c == EOF || getchar() == EOF); } int main() { input(); assert(1 <= n && n <= 200000); int num_sum[200001] = { 0 }; for (int i = 0; i < n; i++) assert(1 <= a[i] && a[i] <= 200000), 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[std::min(200000, (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; }