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