#include <bits/stdc++.h>
int main(void) {
  int a[3000], N, amax = -1;
  unsigned long fmax = 0, temp;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    if (amax < a[i]) amax = a[i];
  }
  for (int i = 1; i < 1000000; i++) {
    temp = 0;
    for (int j = 0; j < N; j++) {
      temp += ((i * amax) - 1) % a[j];
    }
    if (temp > fmax) fmax = temp;
  }
  printf("%ld\n", fmax);
}
