#include <bits/stdc++.h>
int n, a[5010], ans, maxn = -1e5;
using namespace std;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= 100000; i++) {
    ans = 0;
    for (int j = 1; j <= n; j++) {
      ans += i % a[j];
    }
    maxn = max(maxn, ans);
  }
  cout << maxn << endl;
  return 0;
}
