#include using namespace std; const int N = 2e5 + 10; int n, a[N]; vector sub[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1, x; i <= n; i ++) { cin >> x; a[x] ++; } long long ans = 0, mod = 0; for(int i = 1; i < N; i ++) { for(int j = i; j < N; j += i) sub[j].push_back(i); for(auto x : sub[i]) mod += x * (long long)a[x]; ans += a[i] * ((long long)i * n - mod); } cout << ans; }