#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int m, long long int n) {
  if (m % n == 0) return n;
  return gcd(n, m % n);
}
int main() {
  long long int n, a[3010];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int m = 1;
  for (int i = 0; i < n; i++) {
    m = m * a[i] / gcd(m, a[i]);
  }
  long long int S = 0;
  long long int s = 0;
  for (int k = 0; k < m; k++) {
    for (int i = 0; i < n; i++) {
      s += k % a[i];
    }
    S = max(s, S);
  }
  cout << S << endl;
  return 0;
}
