#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rd(T &x) {
  char ch;
  x = 0;
  bool fl = false;
  while (!isdigit(ch = getchar())) (ch == '-') && (fl = true);
  for (x = (ch ^ '0'); isdigit(ch = getchar()); x = x * 10 + (ch ^ '0'))
    ;
  (fl == true) && (x = -x);
}
template <class T>
inline void output(T x) {
  if (x / 10) output(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void ot(T x) {
  if (x < 0) putchar('-'), x = -x;
  output(x);
  putchar(' ');
}
template <class T>
inline void prt(T a[], int st, int nd) {
  for (register int i = st; i <= nd; ++i) ot(a[i]);
  putchar('\n');
}
namespace Modulo {
const int mod = 998244353;
int ad(int x, int y) { return (x + y) >= mod ? x + y - mod : x + y; }
void inc(int &x, int y) { x = ad(x, y); }
int mul(int x, int y) { return (long long)x * y % mod; }
void inc2(int &x, int y) { x = mul(x, y); }
int qm(int x, int y = mod - 2) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = mul(x, ret);
    x = mul(x, x);
    y >>= 1;
  }
  return ret;
}
}  // namespace Modulo
const int N = 200000 + 5;
int n;
long long a[N];
map<long long, long long, greater<long long> > mp;
long long tmp[5 * N];
int main() {
  rd(n);
  for (register int i = 1; i <= n; ++i) rd(a[i]);
  mp[a[1] - 1] = 0;
  for (register int i = 1; i < n; ++i) {
    int ptr = 0;
    for (const auto &x : mp) {
      if (x.first < a[i + 1]) break;
      mp[a[i + 1] - 1] =
          max(mp[a[i + 1] - 1],
              mp[x.first] + (long long)i * a[i + 1] *
                                ((x.first - a[i + 1] + 1) / a[i + 1]));
      mp[x.first % a[i + 1]] =
          max(mp[x.first % a[i + 1]],
              mp[x.first] + (long long)i * (x.first - x.first % a[i + 1]));
      tmp[++ptr] = x.first;
    }
    while (ptr) mp.erase(tmp[ptr--]);
  }
  long long ans = 0;
  for (const auto &x : mp) {
    ans = max(ans, (long long)x.first * n + x.second);
  }
  ot(ans);
  return 0;
}
