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