#include #include using namespace std; int main() { int n; cin >> n; int a[n]; long long s[n+1]; s[0] = 0; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a+n); for (int i = 0; i < n; i++) { s[i+1] = s[i] + a[i]; } long long ans = 0; for (int i = 0; i < n; i++) { for (int m = 0; m <= 2e5; m += a[i]) { int l = lower_bound(a, a+n, m) - a, r = lower_bound(a, a+n, m+a[i]) - a; ans += s[r] - s[l] - (long long)m * (r - l); } } cout << ans << endl; }