#include <bits/stdc++.h>
using namespace std;
unsigned long long gcd(unsigned long long m, unsigned long long n) {
  if (m % n == 0) return n;
  return gcd(n, m % n);
}
int main() {
  unsigned long long n, a[3010];
  cin >> n;
  for (unsigned long long i = 0; i < n; i++) cin >> a[i];
  unsigned long long m = 1;
  for (unsigned long long i = 0; i < n; i++) {
    m *= a[i] / gcd(m, a[i]);
  }
  unsigned long long s = 0;
  unsigned long long S = 0;
  for (unsigned long long k = 1; k < 2000; k++) {
    s = 0;
    for (unsigned long long i = 0; i < n; i++) {
      s += (m * k - 1) % a[i];
    }
    S = max(s, S);
  }
  cout << S << endl;
  return 0;
}
