#include using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector cnt(200010, 0); for (int i = 0; i < n; i++) { int a; cin >> a; ++cnt[a]; } // 0 1 2 3 0 0 0 0 // 0 1 1 1 -3 0 0 0 // 0 1 0 0 -4 3 0 0 ll ans = 0, memo = cnt[1]; vector dp(200010, 0); for (int i = 2; i <= 200000; i++) { if (!cnt[i]) continue; ans += memo * cnt[i]; for (int j = i; j <= 200000; j += i) { dp[j + 1] += cnt[i]; if (j + i <= 200000) dp[j + i] -= i * cnt[i]; if (j + i + 1 <= 200000) dp[j + i + 1] += (i - 1) * cnt[i]; } memo += cnt[i] * i; } for (int i = 1; i <= 200000; i++) { dp[i] += dp[i - 1]; } for (int i = 1; i <= 200000; i++) { dp[i] += dp[i - 1]; } for (int i = 0; i <= 200000; i++) { ans += dp[i] * cnt[i]; } cout << ans << newl; return 0; }