#include <bits/stdc++.h>
using namespace std;
int gcm(int a, int b) {
  int result = a;
  int k = 0;
  int n = b;
  do {
    k = result % n;
    result = n;
    n = k;
  } while (k != 0);
  return result;
}
int lcm(int a, int b) {
  int g;
  g = gcm(a, b);
  return a * b / g;
}
int main() {
  int n;
  int a[3010];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int l = a[0];
  for (int i = 1; i < n; i++) {
    l = lcm(l, a[i]);
  }
  int mod_max = 0;
  for (int m = 1; m <= l; 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;
}
