#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return b / gcd(b, a % b) * a; }
int main() {
  long long n, d, dd;
  cin >> n;
  vector<long long> v(n);
  cin >> v[0];
  d = v[0];
  for (int i = 1; i < n; ++i) {
    cin >> v[i];
    d = lcm(d, v[i]);
  }
  long long ans = 0;
  for (int i = 0; i < (n); i++) ans += (d - 1) % v[i];
  long long ans2 = 0;
  for (int i = 0; i < (n); i++) ans2 += (d + 1) % v[i];
  cout << max(ans, ans2) << endl;
  return 0;
}
