#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, v, r = 200000; cin >> n; vector a(n); vector cnt(r + 2), s(r + 2); for(int i = 0; i < n; i++){ cin >> v; cnt[v + 1]++; s[v + 1] += v; } for(int i = 0; i <= r; i++){ cnt[i + 1] += cnt[i]; s[i + 1] += s[i]; } ll ans = 0; for(int i = 1; i <= r; i++){ if(cnt[i + 1] == cnt[i])continue; ans += (cnt[r + 1] - cnt[i + 1]) * i; for(int j = i; j <= r; j+=i){ ans -= s[min(r + 1, j + i)] - s[j] - (cnt[min(r + 1, j + i)] - cnt[j]) * j; } } cout << ans << '\n'; }