#include <bits/stdc++.h>
using namespace std;
int calc_sum(int m, vector<int> a) {
  int sum = 0;
  for (int num : a) {
    sum += m % num;
  }
  return sum;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a;
  int num;
  for (int _ = (0); _ < (n); ++_) {
    cin >> num;
    a.push_back(num);
  }
  int res = -1;
  for (int i = (0); i < (n); ++i) {
    int m = a[i] + a[i] - 1;
    res = max(res, calc_sum(m, a));
  }
  cout << res;
  return 0;
}
