#include <bits/stdc++.h>
using namespace std;
long long a[200000] = {0};
int t[200000] = {0};
int main() {
  int i, j, T, n, max = 0;
  cin >> n;
  for ((i) = (0); (i) < (n); ++(i)) {
    cin >> a[i];
  }
  for ((i) = (0); (i) < (100000); ++(i)) {
    int sum = 0;
    for ((j) = (0); (j) < (n); ++(j)) {
      sum += (i % a[j]);
    }
    if (max < sum) {
      max = sum;
    }
  }
  cout << max << endl;
  return 0;
}
