#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const long double PI = acos(-1.0);
const long long mod1 = inf + 7;
const long long mod2 = inf + 9;
const int MAXN = 500001;
const long double EPS = 1e-9;
int hp = 179;
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  ;
  long long sum = 0;
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < a.size(); ++i) cin >> a[i];
  ;
  long long mxa = *max_element(a.begin(), a.end());
  ;
  for (long long cnt = 1; cnt <= 1e5; ++cnt) {
    long long ns = 0;
    for (long long i = 0; i < n; ++i) {
      ns += (mxa * cnt - 1) % a[i];
    }
    sum = max(sum, ns);
  }
  cout << sum;
  system("pause");
}
