#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long int *a = new long long int[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  long long int max = 0;
  long long int tmp_max = 0;
  int m = 1;
  while (true) {
    tmp_max = 0;
    for (int i = 0; i < N; i++) {
      tmp_max += (m % a[i]);
    }
    if (max < tmp_max) {
      max = tmp_max;
    }
    m++;
    if (tmp_max == 0) break;
  }
  cout << max << endl;
  return 0;
}
