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