#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int num[3001];
  int m = 1;
  int max = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  for (int i = 1000000; i > 0; i--) {
    int temp = 0;
    for (int j = 0; j < n; j++) {
      temp += i % num[j];
    }
    if (temp > max) {
      max = temp;
    }
  }
  cout << max << endl;
}
