#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a[3010];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int max = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > max) {
      max = a[i];
    }
  }
  int mod_max = 0;
  for (int m = 10; m < 1000000; m++) {
    int sum = m % a[0];
    for (int j = 1; j < n; j++) {
      int amari = m % a[j];
      sum += amari;
    }
    if (sum > mod_max) {
      mod_max = sum;
    }
  }
  cout << mod_max << endl;
}
