#include <bits/stdc++.h>
using namespace std;
const long long int m = pow(10, 9) + 7;
long long int gcd(long long int a, long long int b) {
  if (a < b)
    return gcd(b, a);
  else if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long int n, f = 0, ans = 0, g, p = 1, ans1 = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p *= a[i];
  }
  for (int i = 1; i < n; i++) {
    g = gcd(g, a[i]);
  }
  f = p / g;
  for (int i = 1; i < f; i++) {
    ans = 0;
    for (int j = 0; j < n; j++) {
      ans += i % a[j];
    }
    ans1 = max(ans, ans1);
  }
  cout << endl << ans1 << endl;
  return 0;
}
