#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX = 2e5 + 5;
const long long MAX2 = 11;
const long long MOD = 1100000007;
const long long MOD2 = 1000005329;
const long long INF = 2e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 1000;
long long n, x[MAX], nr, nx;
map<long long, long long> dp[MAX];
vector<pair<long long, int>> v;
long long f(int nw, long long r) {
  if (!r) return 0;
  if (nw == n) return n * r;
  if (dp[nw].count(r)) return dp[nw][r];
  if (r < x[nw + 1]) return dp[nw][r] = f(nw + 1, r);
  nr = r % x[nw + 1];
  nx = (*upper_bound(v.begin(), v.end(), make_pair(nr, MAX))).second;
  long long ret = f(nx, nr) + nw * (r - r % x[nw + 1]);
  nr = x[nw + 1] - 1;
  nx = (*upper_bound(v.begin(), v.end(), make_pair(nr, MAX))).second;
  return dp[nw][r] = max(ret, f(nx, nr) + nw * (r - r % x[nw + 1] - x[nw + 1]));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> x[i];
    if (i > 1) x[i] = min(x[i - 1], x[i]);
  }
  for (int i = n; i >= 1; --i)
    if (x[i] != x[i + 1]) v.push_back({x[i], i});
  cout << f((*upper_bound(v.begin(), v.end(), make_pair(x[1] - 1, MAX))).second,
            x[1] - 1)
       << '\n';
  return 0;
}
