#include <bits/stdc++.h>
using namespace std;
map<int, int> calc(int n) {
  map<int, int> ret;
  int a = 2;
  while (n >= a * a) {
    if (n % a == 0) {
      auto it = ret.find(a);
      if (it != ret.end()) {
        it->second += 1;
      } else {
        ret[a] = 1;
      }
      n /= a;
    } else {
      a++;
    }
  }
  auto it = ret.find(n);
  if (it != ret.end()) {
    it->second += 1;
  } else {
    ret[n] = 1;
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> b[n];
  for (int i = 0; i < n; i++) {
    b[i] = calc(a[i]);
  }
  map<int, int> sum;
  for (int i = 0; i < n; i++) {
    for (auto it = b[i].begin(); it != b[i].end(); ++it) {
      auto sum_it = sum.find(it->first);
      if (sum_it != sum.end()) {
        if (sum[it->first] < it->second) {
          sum[it->first] = it->second;
        }
      } else {
        sum[it->first] = it->second;
      }
    }
  }
  int c = 1;
  for (auto it = sum.begin(); it != sum.end(); ++it) {
    for (int i = 0; i < it->second; i++) {
      c *= it->first;
    }
  }
  int ret = 0;
  int s = c - 1;
  for (int i = 0; i < n; i++) {
    int tmp = s % a[i];
    ret += tmp;
  }
  cout << ret << endl;
  return 0;
}
