#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int g = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    g = gcd(g, a[i]);
  }
  if (n == 1) {
    cout << a[0] - 1 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i] - g;
  }
  cout << ans << endl;
}
