#include <bits/stdc++.h>
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int point = 0;
  for (int i = a[0] * a[1]; i < 1000000; ++i) {
    int tmp = 0;
    for (int j = 0; j < n; ++j) {
      tmp += i % a[j];
    }
    point = max(point, tmp);
  }
  printf("%d", point);
}
