#include using namespace std; using ll = long long; int main(){ int n, v, r = 200000; cin >> 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'; }