#include <bits/stdc++.h>
using namespace std;
int a[4000];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a, a + n + 1);
  int maxn = -0x3f3f3f3f;
  for (int i = a[n] + 1; i <= a[n] + 1000000; i++) {
    int cnt = 0;
    for (int j = 1; j <= n; j++) {
      cnt += i % a[j];
    }
    maxn = max(cnt, maxn);
  }
  cout << maxn << endl;
  return 0;
}
