#include using namespace std; using ll = long long; char buf[1 << 20], *p1, *p2; #define gc() \ (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) \ ? EOF \ : *p1++) inline int read() { int s = 0; for(char ch; ch = gc();) { if(isdigit(ch)) { s = s * 10 + ch - '0'; break; } } for(char ch; ch = gc();) { if(isdigit(ch)) { s = s * 10 + ch - '0'; }else{ break; } } return s; } const int MAXN = 2e5 + 25; int n; ll ans; int a[MAXN]; ll c[MAXN]; int cnt[MAXN]; int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); n = read(); for(int i = 1; i <= n; i++) { a[i] = read(); ans += a[i]; cnt[a[i]]++; } ans *= n; for(int i = 1; i <= 2e5; i++) { if(cnt[i] != 0){ for(int j = i; j <= 2e5; j += i) { c[j] += 1LL * cnt[i] * i; } } c[i] += c[i - 1]; } for(int i = 1; i <= n; i++) { ans -= c[a[i]]; } cout << ans; return 0; }