#include //#include //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector vec; typedef vector mat; ll N,M,H,W,Q,K,A,B; string S; typedef pair P; const ll INF = (1LL<<60); template bool chmin(T &a, const T &b){ if(a > b) {a = b; return true;} else return false; } template bool chmax(T &a, const T &b){ if(a < b) {a = b; return true;} else return false; } int main() { cin>>N; const int max_A = (int)2e+5; vec a(N), num(max_A + 1, 0); rep(i, N){ cin>>a[i]; ++num[a[i]]; } rep(i, max_A) num[i + 1] += num[i]; ll res(0), sum = accumulate(ALL(a), 0LL); rep(i, max_A){ ll now = i + 1; if(num[now] - num[now - 1] > 0){ ll temp(sum); for(ll j = now - 1; j <= max_A; j += now){ temp -= now * (N - num[j]); } //cout<