#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
map<long long, long long> f;
map<long long, long long>::iterator it;
int n;
inline long long rd() {
  long long x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}
int main() {
  n = rd();
  f[rd() - 1] = 0;
  for (int i = 2; i <= n; ++i) {
    long long x = rd();
    while (!f.empty()) {
      it = f.end();
      --it;
      long long a = it->first, b = it->second;
      if (a < x) break;
      f.erase(it);
      f[x - 1] = max(f[x - 1], b + 1ll * (i - 1) * (a - a % x - x));
      f[a % x] = max(f[a % x], b + 1ll * (i - 1) * (a - a % x));
    }
  }
  long long ans = 0;
  for (it = f.begin(); it != f.end(); ++it)
    ans = max(ans, it->first * n + it->second);
  cout << ans;
  return 0;
}
