#include <bits/stdc++.h>
int func(int, int*);
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int i;
  int* p = a;
  for (i = 1; i <= n; i++) {
    scanf("%d", p);
    p++;
  }
  printf("%d\n", func(n, a));
}
int func(int size, int* p) {
  int i, n;
  int max = 0;
  int modsum = 0;
  for (i = 1; i < INT_MAX; i++) {
    modsum = 0;
    for (n = 0; n < size; n++) {
      modsum += i % p[n];
    }
    if (modsum > max) max = modsum;
    if (modsum == 0) break;
  }
  return max;
}
