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