#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, sum1 = 0, sum2 = 0;
  int a[3002];
  while (cin >> n) {
    sum = sum1 = sum2 = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum = sum + a[i];
    }
    sort(a, a + n);
    for (int j = a[0] - 1; j <= sum; j++) {
      sum1 = 0;
      for (int i = 0; i < n; i++) {
        sum1 = sum1 + j % a[i];
      }
      if (sum1 > sum2) {
        sum2 = sum1;
      }
    }
    cout << sum2 << endl;
  }
  return 0;
}
