#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long a[100001];
  long long f = 0;
  long long Ans = 0;
  long long temp;
  long long lcm;
  long long r = 0;
  long long x;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  reverse(a, a + N);
  long long b[100001];
  for (int i = 0; i < N; i++) {
    b[i] = a[i];
  }
  x = b[0] * b[1];
  if (b[0] < b[1]) {
    temp = b[0];
    b[0] = b[1];
    b[1] = temp;
  }
  r = b[0] % b[1];
  while (r != 0) {
    b[0] = b[1];
    b[1] = r;
    r = b[0] % b[1];
  }
  lcm = x / b[1];
  for (int i = 1; i < N - 1; i++) {
    x = lcm * b[i + 1];
    if (lcm < b[i + 1]) {
      temp = lcm;
      lcm = b[i + 1];
      b[i + 1] = temp;
    }
    r = lcm % b[i + 1];
    while (r != 0) {
      lcm = b[i + 1];
      b[i + 1] = r;
      r = lcm % b[i + 1];
    }
    lcm = x / b[i + 1];
  }
  for (int i = 0; i < lcm; i++) {
    f = 0;
    for (int j = 0; j < N; j++) {
      f += i % a[j];
    }
    if (Ans < f) {
      Ans = f;
    }
  }
  cout << Ans;
  return 0;
}
