#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], ans;
long long gcd(long long x, long long y) {
  if (x % y == 0) {
    return y;
  }
  return gcd(y, x % y);
}
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long c = (a[0] * a[1]) / gcd(a[0], a[1]);
  for (long long i = 2; i < n; i++) {
    c = (c * a[i]) / gcd(c, a[i]);
  }
  for (long long i = 0; i < n; i++) {
    ans += (c - 1) % a[i];
  }
  long long ans2 = 0;
  for (long long i = 0; i < n; i++) {
    ans2 += (c + 1) % a[i];
  }
  cout << max(ans, ans2) << endl;
  return 0;
}
