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