#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a, int64_t b) { return (a % b == 0 ? b : gcd(b, a % b)); }
int64_t lcm(int64_t a, int64_t b) { return a * b / gcd(a, b); }
int main() {
  int64_t n, b, ans = 0;
  vector<int> a(3000);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < 10000000 / n; i++) {
    b = 0;
    for (int j = 0; j < n; j++) b += (i % a[j]);
    ans = max(b, ans);
  }
  cout << ans << endl;
}
