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