#include <bits/stdc++.h>
using namespace std;
long int gcd(long int m, long int n) {
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}
long int lcm(long int m, long int n) { return ((m / gcd(m, n)) * n); }
long int culc(long int *a, int N) {
  long int temp;
  long int ans = 0;
  for (int i = 1; i < N; i++) {
    if (i == 1)
      temp = lcm(a[0], a[1]);
    else
      temp = lcm(temp, a[i]);
  }
  long int max = temp;
  for (long int m = 1; m < max; m++) {
    temp = 0;
    for (int i = 0; i < N; i++) {
      temp += m % a[i];
    }
    if (temp > ans) ans = temp;
  }
  return ans;
}
int main() {
  int N;
  cin >> N;
  long int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  cout << culc(a, N) << endl;
}
