#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const long long inf = 1e18;
bool compare(pair<int, string> a, pair<int, string> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int mx = 0;
  for (int i = 1; i <= 1000000; i++) {
    int tot = 0;
    for (int j = 0; j < N; j++) tot += i % a[j];
    mx = max(mx, tot);
  }
  cout << mx << endl;
  return 0;
}
