#include using namespace std; typedef long long ll; const int M = 200000; int main() { int n; cin >> n; bool b[200005]{0}; int d[200005]{0}; for (int i = 0; i < n; i++) { int a; cin >> a; b[a] = true; d[a] = a; } ll c[200005], s[200005]; c[0] = s[0] = 0; for (int i = 1; i <= M + 1; i++) { c[i] = c[i - 1] + b[i - 1]; s[i] = s[i - 1] + d[i - 1]; } ll ans = 0; int e = 0; for (int i = 1; i <= M; i++) { if (b[i]) { ans += i * (n - e - 1); e++; } } for (int i = M; i > 0; i--) { if (!b[i]) { continue; } int r = i; for (int j = 2; j * j <= i; j++) { int l = i / j + 1; ans -= -(s[r] - s[l]) * (j - 1) + (c[r] - c[l]) * (i % l + l * (j - 1)); r = l; } for (int j = 1; j < r; j++) { if (b[j]) { ans -= i % j; } } } cout << ans << endl; }