#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long a[N];
  for (int i = 0; i < N; ++i) cin >> a[i];
  int res = -1;
  for (int i = 1; i < 1000000; ++i) {
    int sum = 0;
    for (int j = 0; j < N; ++j) sum += i % a[j];
    if (res < sum) {
      res = sum;
    }
  }
  cout << res << endl;
  return 0;
}
