#include <bits/stdc++.h>
int main() {
  using namespace std;
  int n, ans = 0, sum = 0;
  cin >> n;
  vector<int> data;
  data.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }
  for (int i = 0; i < 100000 * n; i++) {
    for (int j : data) {
      sum += i % j;
    }
    if (sum > ans) {
      ans = sum;
    }
    sum = 0;
  }
  cout << ans << endl;
  return 0;
}
