#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using db = double;
inline void maxto(ll &a, ll b) { a = max(a, b); }
int n;
map<ll, ll> s;
int main() {
  cin >> n;
  for (ll i = 0; i < n; ++i) {
    ll m;
    scanf("%lld", &m);
    if (!i) {
      s[m - 1] = 0;
      continue;
    }
    while (s.rbegin()->first >= m) {
      auto x = *s.rbegin();
      s.erase(--s.end());
      maxto(s[x.first % m], x.second + (x.first / m * m) * i);
      maxto(s[m - 1], x.second + (x.first / m * m - m) * i);
    }
  }
  ll ans = 0;
  for (auto i : s) maxto(ans, i.first * n + i.second);
  cout << ans << endl;
  return 0;
}
