#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int max = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (max < a[i]) {
      max = a[i];
    }
  }
  int m = 0;
  int t = 0;
  max = 2 * max - 1;
  for (int i = max; i > 0; i--) {
    for (int i = 0; i < n; i++) {
      t = t + max % a[i];
    }
    if (m < t) {
      m = t;
    }
    t = 0;
  }
  printf("%d", m);
}
