#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i < 100000; i++) {
    int mods = 0;
    for (int j = 0; j < (int)(n); j++) {
      mods += i % a[j];
    }
    ans = max(ans, mods);
  }
  cout << ans << endl;
}
