#include <bits/stdc++.h>
using namespace std;
int lcm(long long int a, long long int b) {
  long long int x = a * b;
  if (a < b) {
    long long int tmp = a;
    a = b;
    b = tmp;
  }
  long long int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return x / b;
}
int main() {
  int N, max = 0, f;
  long long int max_a;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (i == 0) max_a = a[i];
  }
  max_a = 10000000;
  for (long long int m = 0; m < max_a; m++) {
    f = 0;
    for (int i = 0; i < N; i++) {
      f += m % a[i];
    }
    if (f > max) max = f;
  }
  cout << max << endl;
  return 0;
}
