#include <bits/stdc++.h>
using namespace std;
const int DN = 5e4 + 5, DM = 105;
long long n, a[DN], fr[DM], f, sum, mi = 1e18, b[DN], z;
long long dp[2][DN];
priority_queue<long long> q;
void op(long long d, long long f, long long g) {
  z = sum - f;
  f /= d;
  z += f;
  z -= g;
  z += g * d;
  mi = min(mi, z);
}
void solve(long long f, long long g) {
  for (int d = 1; d * d <= f; d++)
    if (f % d == 0) {
      op(d, f, g);
      op(f / d, f, g);
    }
}
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (n == 1) {
    cout << a[1];
    return 0;
  }
  mi = sum;
  dp[0][0] = dp[1][n + 1] = 1e18;
  for (int i = 1; i <= n; i++) dp[0][i] = min(a[i], dp[0][i - 1]);
  for (int i = n; i > 0; i--) dp[1][i] = min(dp[1][i + 1], a[i]);
  for (int i = 1; i <= n; i++) solve(a[i], min(dp[0][i - 1], dp[1][i + 1]));
  cout << mi;
}
