#include <bits/stdc++.h>
int a[5000];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int i, j;
    int max = 1;
    memset(a, 0, sizeof(a));
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    int t = i;
    int sum;
    for (i = 0; i < 10000; i++) {
      sum = 0;
      for (j = 0; j < t; j++) {
        sum += i % a[j];
      }
      if (sum > max) max = sum;
    }
    printf("%d\n", max);
  }
}
