#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int mx = 0;
  for (int i = 1; i <= 100000000; i++) {
    int num = 0;
    for (int j = 1; j <= n; j++) {
      num += i % a[j];
    }
    mx = max(mx, num);
  }
  cout << mx << endl;
}
