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