#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int inf = 10000000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long long a[N];
  long long mul = 1;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    mul = mul * a[i] / gcd(mul, a[i]);
  }
  long long max = 0;
  for (long long i = mul - 1; i < mul; i++) {
    long long tmp = 0;
    for (int j = 0; j < N; j++) {
      tmp += i % a[j];
    }
    if (tmp > max) {
      max = tmp;
    }
  }
  cout << max << endl;
  return 0;
}
