#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, j, maxx = 0, summ;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 1; i <= 30000; i++) {
    summ = 0;
    for (j = 0; j < n; j++) {
      summ += (i % a[j]);
    }
    if (summ > maxx) maxx = summ;
  }
  cout << maxx;
}
