#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  long long int pos, max = INT_MIN;
  for (int m = 1; m <= 100000; ++m) {
    long long int ch = 0;
    for (int i = 0; i < n; ++i) {
      ch += m % ar[i];
    }
    if (max < ch) {
      max = ch;
      pos = m;
    }
  }
  cout << max;
  return (0);
}
