#include <bits/stdc++.h>
using namespace std;
int func(int m, vector<int> vec) {
  int ret = 0;
  for (int v : vec) ret += (m % v);
  return ret;
}
int main() {
  int n, ans = 0, tmp = 0;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  for (int i = *min_element(A.begin(), A.end()); i < 10e5; ++i)
    ans = max(ans, func(i, A));
  cout << ans << "\n";
}
