#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  int maxx = 0;
  int minn = 1e9;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    maxx = max(maxx, a[i]);
    minn = min(minn, a[i]);
  }
  for (int i = minn; i < maxx * 999; ++i) {
    int sum = 0;
    for (int j = 0; j < (n); ++j) {
      sum += i % a[j];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
