#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N];
  int max_element = 2;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    max_element = max(max_element, a[i]);
  }
  int ans = 0;
  for (int m = max_element; m < 2 * 1000000; m++) {
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += (m % a[i]);
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
