#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long int gcd(long long int x, long long int y) {
  long long int r;
  while ((r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y;
}
long long int lcm(long long int x, long long int y) {
  return (y / gcd(x, y) * x);
}
int main() {
  long long n;
  cin >> n;
  long long a[n];
  long long maxi = -1;
  for (long long i = 0; i < (n); i++) {
    cin >> a[i];
    maxi = max(a[i], maxi);
  }
  long long temp = a[0];
  for (long long i = 0; i < (n); i++) {
    temp = max(temp, lcm(temp, a[i]));
  }
  long long res = 0;
  long long res2 = 0;
  for (long long i = 0; i < (n); i++) {
    res += (temp - 1) % a[i];
    res2 += (maxi - 1) % a[i];
  }
  cout << max(res, res2) << endl;
  return 0;
}
