#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, a[3000];
  cin >> N;
  int ma = -1;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    ma = max(ma, a[i]);
  }
  long long vmax = 0;
  for (int m = 0; m < 1000000; m++) {
    long long v = 0;
    for (int i = 0; i < N; i++) {
      v += m % a[i];
    }
    vmax = max(v, vmax);
  }
  cout << vmax << endl;
}
