#include <bits/stdc++.h>
int main() {
  long long int n, a[3001], i, j, f, max, fmax = 0;
  ;
  scanf("%lld", &n);
  max = 0;
  for (i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    if (a[i] > max) max = a[i];
  }
  for (i = max; i < (max * 2); ++i) {
    for (j = 0; j < n; ++j) {
      f += i % a[j];
    }
    if (f > fmax) fmax = f;
  }
  printf("%lld", fmax);
  return 0;
}
