#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int *a = new long long int[n];
  long long int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int maxE = *max_element(a, a + n);
  long long int maxS = 0;
  for (int i = maxE; i < maxE * 2; ++i) {
    for (int j = 0; j < n; ++j) {
      sum += (i % a[j]);
    }
    maxS = max(maxS, sum);
    sum = 0;
  }
  cout << maxS << endl;
  return 0;
}
