#include <bits/stdc++.h>
using namespace std;
int a[4000];
int main() {
  int n;
  int sum = 0;
  int maxnum = -1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= 100000; i++) {
    for (int j = 1; j <= n; j++) {
      sum += i % a[j];
    }
    if (sum > maxnum) maxnum = sum;
    sum = 0;
  }
  cout << maxnum << endl;
  return 0;
}
