#include <bits/stdc++.h>
using namespace std;
;
const int maxx = 1e6 + 9;
int remSum(int m, vector<int> arr) {
  int c = 0;
  for (int x : arr) {
    c += (m % x);
  }
  return c;
}
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  int curr = 0;
  for (int i = 1; i <= 1000000; i++) {
    ans = max(ans, remSum(i, arr));
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t-- > 0) {
    solve();
  }
  return 0;
}
