#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[3000], i, j, max;
  while (cin >> n) {
    int b[10001] = {0};
    max = 0;
    for (i = 0; i < n; i++) cin >> a[i];
    for (j = 0; j <= 10000; j++) {
      for (i = 0; i < n; i++) {
        b[j] += j % a[i];
      }
    }
    for (j = 0; j <= 10000; j++) {
      if (max < b[j]) max = b[j];
    }
    cout << max;
  }
  return 0;
}
