#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a[5000], max = -1, tmp;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int m = 0; m < 100000; m++) {
    tmp = 0;
    for (int j = 0; j < N; j++) {
      tmp += m % a[j];
    }
    if (max < tmp) max = tmp;
  }
  cout << max << endl;
  return 0;
}
