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