#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &x, T y) {
  return (y < x) ? (x = y, 1) : 0;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return (y > x) ? (x = y, 1) : 0;
}
inline int read() {
  int x;
  char c;
  int f = 1;
  while ((c = getchar()) != '-' && (c > '9' || c < '0'))
    ;
  if (c == '-') f = -1, c = getchar();
  x = c ^ '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ '0');
  return x * f;
}
inline long long readll() {
  long long x;
  char c;
  int f = 1;
  while ((c = getchar()) != '-' && (c > '9' || c < '0'))
    ;
  if (c == '-') f = -1, c = getchar();
  x = c ^ '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = (x << 1ll) + (x << 3ll) + (c ^ '0');
  return x * f;
}
const int maxn = 2e5 + 10;
map<long long, long long> mp;
map<long long, long long>::iterator it, it1;
long long a[maxn];
int main() {
  int n = read();
  for (register int i = 1, iend = n; i <= iend; ++i) a[i] = readll();
  mp[a[1] - 1] = 0;
  for (register int i = 2, iend = n; i <= iend; ++i)
    for (it = mp.lower_bound(a[i]); it != mp.end();) {
      chkmax(mp[(it->first) % a[i]],
             (it->second) + ((it->first) / a[i]) * a[i] * (i - 1));
      chkmax(mp[a[i] - 1],
             (((it->first) + 1) / a[i] - 1) * a[i] * (i - 1) + (it->second));
      it1 = it;
      ++it;
      mp.erase(it1);
    }
  long long ans = 0;
  for (auto v : mp) chkmax(ans, v.second + v.first * n);
  printf("%lld\n", ans);
  return 0;
}
