#include <bits/stdc++.h>
using namespace std;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
static void redirect(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (argc > 1) {
    static filebuf f;
    f.open(argv[1], ios::in);
    cin.rdbuf(&f);
    if (!cin) {
      cerr << "Failed to open '" << argv[1] << "'" << endl;
      exit(1);
    }
  }
  if (argc > 2) {
    static filebuf f;
    f.open(argv[2], ios::out | ios::trunc);
    cout.rdbuf(&f);
    if (!cout) {
      cerr << "Failed to open '" << argv[2] << "'" << endl;
    }
  }
}
static vector<long long> a;
static vector<long long> best;
static long long query(long long x, int i) {
  int N = ((long long)(a).size());
  if (i == -1)
    i = upper_bound(begin(a), end(a), x, greater<long long>()) - a.begin();
  if (i == N) return (x - 1) * N;
  long long q = x / a[i];
  long long r = x % a[i];
  long long score = (q - 1) * i * a[i] + best[i];
  if (r > 0) {
    long long score2 = q * i * a[i] + query(r, -1);
    score = max(score, score2);
  }
  return score;
}
int main(int argc, const char **argv) {
  redirect(argc, argv);
  int N;
  cin >> N;
  a.resize(N);
  best.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (i > 0) a[i] = min(a[i], a[i - 1]);
  }
  for (long long i = N - 1; i >= 0; i--) best[i] = query(a[i], i + 1);
  cout << best[0] << '\n';
  return 0;
}
