#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int n;
vector<int> a;
int main() {
  long long ans = 0;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long m = a[n - 1];
  long long tmp = 0;
  for (int i = (int)(n - 1) - 1; i >= (int)(0); --i) {
    m = lcm(m, a[i]);
    tmp = 0;
    for (int j = 0; j < (int)(n); ++j) {
      tmp += (m - 1) % a[j];
    }
    if (ans < tmp) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}
