#include <bits/stdc++.h>
using namespace std;
void to_pray() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr << "Ready\n";
}
const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const long long LLINF = 1e12 + 7;
const long long P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);
int a[N];
int main() {
  to_pray();
  int n;
  cin >> n;
  int mx = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    mx = (a[i] > mx ? a[i] : mx);
  }
  int res = 0;
  sort(a + 1, a + 1 + n);
  for (int i = mx; i <= 100001; ++i) {
    int sum = 0;
    for (int j = 1; j <= n; ++j) {
      sum += (i % a[j]);
    }
    res = (res > sum ? res : sum);
  }
  cout << res;
  cout << '\n';
  return 0;
}
