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