#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  int m = 1;
  int max = 0;
  while (true) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += (m % num[i]);
    }
    if (sum == 0) {
      break;
    } else {
      if (sum > max) {
        max = sum;
      }
    }
    m++;
  }
  cout << max << endl;
  return 0;
}
