#include <bits/stdc++.h>
using namespace std;
int n, num[3001];
int F(int S) {
  int ret = 0;
  for (int i = 0; i < n; i++) {
    ret += S % num[i];
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int maxx = 0, minn = 100024;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    if (num[i] > maxx) {
      maxx = num[i];
    }
    if (num[i] < minn) minn = num[i];
  }
  int maxx2 = 0;
  for (int i = minn; i < 999999; i++) {
    int Fi = F(i);
    if (Fi > maxx2) {
      maxx2 = Fi;
    }
  }
  cout << maxx2;
  return 0;
}
