#include <bits/stdc++.h>
using namespace std;
long long gcd(int a, int b) {
  int v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  };
  return v1;
}
long long lcm(int a, int b) { return a * b / gcd(a, b); }
int main() {
  int N;
  long long x = 1;
  long long ans = 0;
  cin >> N;
  vector<int> a;
  int s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    a.push_back(s);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    s = a[i];
    x = lcm(x, s);
  }
  for (int i = 0; i < N; i++) {
    ans = ans + x % a[i];
  }
  cout << ans << endl;
  return 0;
}
