#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];
  }
  long long maxA = 0;
  long long total = 0;
  for (long long j = 0; j < 100001; j++) {
    total = 0;
    for (int i = 0; i < N; i++) {
      total = total + j % a[i];
    }
    maxA = max(maxA, total);
  }
  cout << maxA << endl;
  return 0;
}
