#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long x, r;
  x = a * b;
  if (a < b) swap(a, b);
  r = a % b;
  while (r) {
    a = b;
    b = r;
    r = a % b;
  }
  return x / b;
}
int main() {
  long long N, x = 1, ans = 0;
  cin >> N;
  long long a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    x = gcd(x, a[i]);
  }
  for (int i = 0; i < N; i++) ans += (x - 1) % a[i];
  cout << ans << endl;
}
