#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n;
long long arr[N];
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
long long f(long long x) {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (x % arr[i]);
  }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long here = arr[0];
  for (int i = 0; i < n; i++) {
    here = lcm(here, arr[i]);
  }
  long long miny = *min_element(arr, arr + n);
  long long ans = -2e18;
  for (int i = 0; i < miny; i++) {
    ans = max(ans, f(here - 1 - i));
  }
  cout << ans << endl;
  return 0;
}
