#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < 1000000000; i++) {
    int num = 0;
    for (int j = 0; j < N; j++) {
      num += i % a[j];
    }
    ans = max(ans, num);
  }
  cout << ans << endl;
}
