#include<cstdio>#include<algorithm>#define maxn 2000005#define int long longusingnamespace std;int n, a[maxn], Max =0, sum =0;signedmain(){scanf("%lld",&n);for(int x, i =1; i <= n; i++)scanf("%lld",&x), a[x]++, Max =max(Max, x), sum += x;for(int i =1; i <= maxn; i++) a[i]+= a[i -1];int ans = sum;for(int i =1; i <= Max; i++){int tot =0;for(int j =1; j * i <= Max +100000; j++)
tot +=(a[j * i -1]- a[(j -1)* i -1])*(j -1);
tot *=(i -1);
ans =min(ans, sum - tot);}printf("%lld\n", ans);return0;}