#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long int INF = 1e18;
const int N = 1e5 + 5;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos(-1.0);
int a[N];
int n;
int num;
long long int calc(int m) {
  long long int ret = 0;
  for (int i = 1; i <= n; i++) ret += (m % a[i]);
  return ret;
}
long long int Ternary_Search() {
  long long int lo = 1, hi = num - 1, it = 300;
  long long int ret = -INF;
  while (it--) {
    long long int midL = (lo + hi) / 2, midR = (lo + hi) / 2 + 1;
    long long int x = calc(midL), y = calc(midR);
    if (x > y)
      ret = max(ret, x), hi = midR;
    else
      ret = max(ret, y), lo = midL;
  }
  ret = max(ret, max(calc(lo), calc(hi)));
  return ret;
}
int main(int argc, char const *argv[]) {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], num = max(num, a[i]);
  long long int mx = 0;
  for (int i = 1; i <= 100000; i++) {
    long long int tot = 0;
    for (int j = 1; j <= n; j++) {
      tot += (i % a[j]);
    }
    mx = max(mx, tot);
  }
  cout << mx << endl;
  return 0;
}
