#include <bits/stdc++.h>
using namespace std;
const int INTINF = 1 << 29;
const long long LLINF = 1LL << 61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DY[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> A;
  int a;
  for (int i = (0); i < (n); ++i) {
    cin >> a;
    A.push_back(a);
  }
  int mx = 0;
  int sm;
  for (int i = (0); i < (100000); ++i) {
    sm = 0;
    for (int j = (0); j < (A.size()); ++j) {
      sm += i % A[j];
    }
    mx = max(mx, sm);
  }
  cout << mx << endl;
}
