#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int main() {
  int n;
  cin >> n;
  int a[n];
  int num = 1;
  cin >> a[0];
  cin >> a[1];
  int l = lcm(a[0], a[1]);
  for (int i = 2; i < n; i++) {
    cin >> a[i];
    l = lcm(l, a[i]);
  }
  int result[l];
  result[0] = 0;
  result[1] = 0;
  for (int i = 2; i < l; i++) {
    result[i] = 0;
    for (int j = 0; j < n; j++) {
      result[i] += i % a[j];
    }
  }
  sort(result, result + l, greater<int>());
  cout << result[0] << endl;
}
