#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], i, f, max = 0;
  long long m;
  for (i = 0; i <= n - 1; i++) cin >> a[i];
  long long mult = 1;
  for (i = 0; i <= n - 1; i++) mult *= a[i];
  for (m = 1; m <= mult - 1; m++) {
    f = 0;
    for (i = 0; i <= n - 1; i++) f += m % a[i];
    if (max < f) max = f;
  }
  cout << max << endl;
  return 0;
}
