#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, a[3000], Sum = 0, max = 0, i, j;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (j = 2; j <= 100000; j++) {
    for (i = 0; i < N; i++) {
      Sum = Sum + (j % a[i]);
    }
    if (Sum > max) {
      max = Sum;
    }
    Sum = 0;
  }
  cout << max << endl;
}
