#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, A[3000], f = 0, max = 0, ans = 0;
  cin >> n;
  for (int i = 0; i < (int)n; i++) {
    cin >> A[i];
  }
  for (int j = 0; j <= 20000000; j++) {
    f = 0;
    for (int i = 0; i < (int)n; i++) {
      f += (j % A[i]);
    }
    if (ans < f) ans = f;
  }
  cout << ans << endl;
}
