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