#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 1e9;
const long long INF = 1LL << 30;
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long l = a[0];
  for (int i = 1; i < n; i++) {
    l = lcm(l, a[i]);
  }
  long long ans = 0;
  for (long long i = l - 1; l > 0; i--) {
    long long sum = 0;
    for (int j = 0; j < n; j++) {
      sum += i % a[j];
    }
    if (ans < sum)
      ans = sum;
    else
      break;
  }
  cout << ans << endl;
}
