#include <bits/stdc++.h>
using namespace std;
const long long MOD = round(1e9 + 7);
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (long long i = 0; i < N; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 1; i < 100001; i++) {
    long long tmp = 0;
    for (long long j = 0; j < N; j++) tmp += i % a[j];
    ans = max(ans, tmp);
  }
  cout << ans << "\n";
  return 0;
}
