#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long a[N], b[N];
  for (int i = 0; i < N; i++) {
    long long tmp;
    cin >> tmp;
    a[i] = tmp;
    b[i] = tmp;
  }
  for (int i = 0; i < N - 1; i++) {
    long long multi = a[i] * a[i + 1];
    long long maxCommon = 0;
    long long A, B;
    if (a[i] > a[i + 1]) {
      A = a[i];
      B = a[i + 1];
    } else {
      A = a[i + 1];
      B = a[i];
    }
    long long r = A % B;
    while (r > 0) {
      A = B;
      B = r;
      r = A % B;
    }
    maxCommon = multi / B;
    a[i + 1] = maxCommon;
  }
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    sum += (a[N - 1] - 1) % b[i];
  }
  cout << sum << endl;
  return 0;
}
