#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
map<long long int, long long int> primes;
long long int f(long long int m) {
  long long int sum = 0;
  for (int i = 0; i < (int)(n); i++) {
    sum += m % a[i];
  }
  return sum;
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    long long int an;
    cin >> an;
    a.push_back(an);
    for (long long int j = 2; j <= an; j++) {
      if (an % j == 0) {
        primes[an] = an;
      }
    }
  }
  long long int all = 1;
  for (auto p : primes) {
    all = p.first * all;
  }
  cout << f(all - 1) << endl;
  return 0;
}
