#include <bits/stdc++.h>
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
using namespace std;
using Graph = vector<vector<int64_t>>;
const double pi = M_PI;
const int64_t MOD = 1000000007;
int Gcd(int a, int b) {
  if (b == 0) {
    return a;
  } else {
    return Gcd(b, a % b);
  }
}
int Lcm(int a, int b) { return (a * b) / Gcd(a, b); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 1; i <= 1000000; i++) {
    int tem = 0;
    for (int k = 0; k < n; k++) {
      tem += i % a[k];
    }
    ans = max(ans, tem);
  }
  cout << ans << endl;
  return 0;
}
