#include <bits/stdc++.h>
using namespace std;
int n, a[10000], maxc = -1, temp, s = 0;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  for (int i = s; i > 0; i--) {
    temp = 0;
    for (int j = 0; j < n; j++) {
      temp += (i % a[j]);
    }
    if (maxc < temp) maxc = temp;
  }
  cout << maxc;
  return 0;
}
