#include using namespace std; using ll = long long; ll u[100005]; vector a[100005]; ll b[1000005]; //void dfs() int main() { ios_base::sync_with_stdio(false); cin.tie(0); for(ll i = 1;i <= 100000;i++) { for(ll j = i;j <= 100000;j += i) { a[j].push_back(i); } } ll n; cin >> n; ll i,j; for(i = 1;i <= n;i++) cin >> b[i]; sort(b + 1,b + 1 + n); ll ans = 0; for(i = 1;i <= n;i++) { ll x = b[i]; //ll y = sqrt(x); if(i == 1) { for(ll tmp = 0;tmp < a[x].size();tmp++) { j = a[x][tmp]; if(u[j] == 0) u[j] = x/j; //else u[j] = min(u[j], x/j); } }else { ll add = LLONG_MAX/2; for(ll tmp = 0;tmp < a[x].size();tmp++) { j = a[x][tmp]; if(u[j] != 0) add = min(add, x * u[j]); //else u[j] = min(u[j], x/j); } for(ll tmp = 0;tmp < a[x].size();tmp++) { j = a[x][tmp]; if(u[j] == 0) u[j] = x/j; //else u[j] = min(u[j], x/j); } ans += add; } } cout << ans; }