#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  long long int tmp = 0LL;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    tmp += a[i];
  }
  int minmod = 100000;
  int mod = 0;
  for (long long int i = tmp; i >= 1; i--) {
    for (int j = 0; j < N; j++) {
      mod += i % a[i];
    }
    minmod = min(mod, minmod);
  }
  cout << minmod;
}
