#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, i, f, sum, e = 1, max = 0;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    e *= a[i];
  }
  for (i = 1; i <= e; i++) {
    f = 0;
    for (int j = 0; j < n; j++) {
      f += i % a[j];
    }
    if (f > max) {
      max = f;
    }
  }
  cout << max;
}
