#include <bits/stdc++.h>
int main(void) {
  int n, i;
  unsigned a[3001];
  unsigned long m, buf, max = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%u", &a[i]);
  for (m = 0; m < 0x100000; m++) {
    buf = 0;
    for (i = 0; i < n; i++) buf += (m % a[i]);
    if (max < buf) max = buf;
  }
  printf("%d\n", max);
  return (0);
}
