#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<unsigned long long> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  unsigned long long f = 0;
  unsigned long long div = a.at(N - 1);
  for (int i = 0; i < N; i++) {
    f += (div % a.at(i));
  }
  cout << f << endl;
}
