#include <bits/stdc++.h>
int main(void) {
  int m, N, i = 0, max = 0, f;
  int a[100000] = {'0'};
  scanf("%d", &N);
  while (i < N) {
    scanf("%d", &a[i]);
    ++i;
  }
  for (m = 1; m < INT_MAX; ++m) {
    f = 0;
    for (i = 0; i < N; ++i) {
      f += (m % a[i]);
    }
    if (max < f) max = f;
  }
  printf("%d\n", max);
  return 0;
}
