#include <bits/stdc++.h>
long long lc(long long a, long long b) {
  long long x = a * b;
  if (a < b) {
    long long tmp = a;
    a = b;
    b = tmp;
  }
  long long r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return x / b;
}
int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  long long a[N];
  for (size_t i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  long long A = 1;
  for (size_t i = 0; i < N; i++) {
    A = lc(A, a[i]);
  }
  long long res = 0;
  for (long long zz = A - 1; zz < A; zz++) {
    long long B = 0;
    for (size_t i2 = 0; i2 < N; i2++) {
      B += zz % a[i2];
    }
    if (B > res) res = B;
  }
  std::cout << res << '\n';
  return 0;
}
