#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  int sum = 0;
  for (int m = 2; m < 100000; m++) {
    sum = 0;
    for (int i = 0; i < n; i++) {
      sum += m % a[i];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
