#include <bits/stdc++.h>
using namespace std;
inline int modfunc(int m, int *a, int N) {
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    sum += m % a[i];
  }
  return sum;
}
int main() {
  int m, a[3100], N;
  int max = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> a[i];
  for (int i = 1; i < 200000000; i++) {
    m = modfunc(i, a, N);
    if (max < m) max = m;
  }
  cout << max << endl;
  return 0;
}
