#include using namespace std; const int N = 2e5 + 5; int n, maxx, a[N]; long long ans, sum, s[N]; int main(){ cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; s[a[i]]++, sum += a[i]; maxx = max(maxx, a[i]); } for(int i = 1; i <= maxx; i++){ s[i] += s[i - 1]; } for(int i = 1; i <= maxx; i++){ long long num = sum, r = 0; for(int j = i - 1, pre = 0, f = 0; j <= maxx; j += i, f++){ num -= (f * i) * (0ll + s[j] - pre); pre = s[j], r = j; } num -= (s[maxx] - s[r]) * (maxx / i * i); ans += (s[i] - s[i - 1]) * num; } cout << ans; return 0; }