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