#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a;
  cin >> N;
  vector<int> v;
  for (int i = 0; i < N; i++) {
    cin >> a;
    v.push_back(a);
  }
  int max = 0, sum = 0;
  for (int i = 2; i <= 10 * 10 * 10 * 10 * 10; i++) {
    sum = 0;
    for (int j = 0; j < v.size(); j++) {
      sum += i % v[j];
    }
    if (max < sum) {
      max = sum;
    }
  }
  cout << max << endl;
  return 0;
}
