#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b);
int lcm(int a, int b);
int main(void) {
  int N;
  vector<int> a;
  int sub;
  int ans = INT_MIN;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> sub;
    a.push_back(sub);
  }
  int upper = lcm(a[0], a[1]);
  for (int i = 2; i < N; i++) {
    upper = max(upper, lcm(upper, a[i]));
  }
  for (int i = 0; i < upper; i++) {
    int f = 0;
    for (int j = 0; j < N; j++) {
      f += i % a[j];
    }
    ans = max(ans, f);
  }
  cout << ans << endl;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
