#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i <= 1e5; i++) {
    int second = 0;
    for (int j = 0; j < n; j++) second += i % a[j];
    ans = max(ans, second);
  }
  cout << ans;
}
