#include <bits/stdc++.h>
int N;
int M;
int a[3100];
using namespace std;
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int cmax = 0;
  int csum = 0;
  for (int i = 0; i < 1e5; ++i) {
    csum = 0;
    for (int j = 0; j < N; ++j) {
      csum += i % a[j];
    }
    if (csum < cmax) {
      cmax = csum;
    }
  }
  cout << cmax;
  return 0;
}
