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