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