#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  ll mi = *min_element(a.begin(), a.end());
  ll ans = 0;
  for (ll i = mi;; i += i) {
    bool can = true;
    for (ll j = 0; j < n; j++) {
      if (i % a[j] != 0) {
        can = false;
      }
    }
    if (can) {
      ans = i - 1;
      break;
    }
  }
  ll res = 0;
  for (ll i = 0; i < n; i++) {
    res += ans % a[i];
  }
  cout << res << endl;
}
