#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcd(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  int n;
  long long a[3001] = {}, lc = 1, ans = 0;
  vector<long long> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i % 2 == 1) v.push_back(lcd(a[i - 1], a[i]));
  }
  if (n % 2 == 1) v.push_back(a[n - 1]);
  while (v.size() != 1) {
    long long x = v.back();
    v.pop_back();
    long long y = v.back();
    v.pop_back();
    v.insert(v.begin(), lcd(x, y));
  }
  lc = v[0];
  lc--;
  for (int i = 0; i < n; i++) {
    ans += lc % a[i];
  }
  cout << ans << endl;
}
