#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
long long solve(long long m, vector<long long>& arr, long long len) {
  long long ans = 0;
  for (long long i = 0; i < len; i++) {
    ans += m % arr[i];
  }
  return ans;
}
int main() {
  long long N;
  cin >> N;
  vector<long long> arr(N);
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    arr[i] = a;
  }
  long long m = arr[0];
  for (int i = 1; i < N; i++) {
    m = lcm(arr[i], m);
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    ans = max(ans, solve(i, arr, N));
  }
  cout << ans << endl;
}
