#include <bits/stdc++.h>
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;
long long f(long long p, long long q) { return q ? f(q, p % q) : p; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> a(N);
  for (int i = (int)0; i < (int)N; ++i) cin >> a[i];
  sort((a).begin(), (a).end(), [](long long p, long long q) { return p > q; });
  long long tmp = a[0];
  for (int i = (int)0; i < (int)N; ++i) {
    tmp = tmp * a[i] / f(tmp, a[i]);
  }
  long long ans = 0ll;
  for (int i = (int)0; i < (int)N; ++i) {
    ans += tmp - 1ll > a[i] ? (tmp - 1ll) % a[i] : (tmp - 1ll);
  }
  cout << ans << endl;
  return 0;
}
