#include <bits/stdc++.h>
int main() {
  long long n;
  std::cin >> n;
  std::vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    std::cin >> v[i];
  }
  std::map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    long long a = v[i];
    long long num = 2;
    long long count = 0;
    while (a != 1) {
      while (a % num == 0) {
        count++;
        a /= num;
      }
      m[num] = std::max(m[num], count);
      count = 0;
      num++;
    }
  }
  long long ans = 1;
  for (auto a : m) {
    for (long long i = 0; i < a.second; i++) {
      ans *= a.first;
    }
  }
  ans--;
  long long ret = 0;
  for (long long i = 0; i < n; i++) {
    ret += ans % v[i];
  }
  std::cout << ret << std::endl;
  return 0;
}
