#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int max_res = 0;
  for (int i = 2; i < 1000; i++) {
    int res = 0;
    int m = a[n - 1] * i - 1;
    for (int i = 0; i < n; i++) {
      res += m % a[i];
    }
    if (max_res < res) max_res = res;
  }
  cout << max_res << endl;
  return 0;
}
