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