#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(a, a % b);
}
int main() {
  long long n, a[3001], max_a;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (max_a == 0)
      max_a = a[i];
    else if (max_a % a[i] != 0) {
      max_a = gcd(a[i], max_a) * max_a;
    }
  }
  long long max_f = 0;
  for (long long m = max_a - 1; m < max_a; m++) {
    long long f = 0;
    for (long long i = 0; i < n; i++) {
      f += m % a[i];
    }
    max_f = f > max_f ? f : max_f;
  }
  cout << max_f << endl;
  return 0;
}
