#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char *argv[]) {
  int N;
  cin >> N;
  int *a;
  a = (int *)malloc(sizeof(int) * N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int ansq = 0;
  for (int m = 0; m < 10000; m++) {
    ansq = 0;
    for (int i = 0; i < N; i++) {
      ansq += m % a[i];
    }
    ans = max(ans, ansq);
  }
  cout << ans;
  return 0;
}
