/* TLE expected */ #include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); std::map a; for (int i = 0; i < n; i++) a[ri()]++; int64_t res = 0; for (auto &i : a) { for (auto &j : a) { res += (int64_t) i.second * j.second * (i.first % j.first); } } std::cout << res << std::endl; return 0; }