#include using namespace std; const int N = 2e5 + 5, INF = 2e5; int n, a[N]; long long ans, sum, maxx, 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, 0ll + 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; j <= maxx; j += i){ num -= (j / i * 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; }