#include <bits/stdc++.h>
using namespace std;
long long GetLeastCommonMultiple(long long a, long long b) {
  long long m = a;
  long long n = b;
  long long temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return a / n * b;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long lcm = a[0];
  for (int i = 1; i < n; i++) {
    lcm = GetLeastCommonMultiple(lcm, a[i]);
  }
  int ans = 0;
  for (int i = 1; i < lcm + 1; i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++) {
      tmp += i % a[j];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
