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