#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200005];
map<long long, long long> M;
pair<long long, long long> V[200005];
void Read() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
}
void Solve() {
  M[A[1] - 1] = 0;
  for (int i = 1; i < N; i++) {
    int cnt = 0;
    long long Max = -1;
    while (!M.empty()) {
      long long a = prev(M.end())->first, b = prev(M.end())->second;
      if (a < A[i + 1]) break;
      long long mod = a % A[i + 1];
      long long newb = a - mod;
      V[++cnt] = make_pair(mod, b + i * newb);
      newb -= A[i + 1];
      Max = max(Max, b + i * newb);
      M.erase(prev(M.end()));
    }
    for (int i = 1; i <= cnt; i++) {
      if (M.find(V[i].first) != M.end())
        M[V[i].first] = max(M[V[i].first], V[i].second);
      else
        M[V[i].first] = V[i].second;
    }
    if (cnt > 0) {
      if (M.find(A[i + 1] - 1) != M.end())
        M[A[i + 1] - 1] = max(M[A[i + 1] - 1], Max);
      else
        M[A[i + 1] - 1] = Max;
    }
  }
  long long ans = 0;
  for (auto it = M.begin(); it != M.end(); it = next(it)) {
    long long a = it->first, b = it->second;
    ans = max(ans, a * N + b);
  }
  cout << ans << "\n";
}
int main() {
  Read();
  Solve();
  return 0;
}
