#include <bits/stdc++.h>
using namespace std;
long long a[202020];
map<long long, long long> mp;
int main() {
  int n;
  scanf("%d", &n);
  long long x;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  mp[a[1] - 1] = 0;
  for (int i = 1; i < n; i++) {
    map<long long, long long>::iterator p = mp.lower_bound(a[i + 1]);
    vector<pair<long long, long long> > v(p, mp.end());
    mp.erase(p, mp.end());
    for (vector<pair<long long, long long> >::iterator it = v.begin();
         it != v.end(); it++) {
      long long r = it->first;
      long long k = it->second;
      mp[a[i + 1] - 1] =
          max(mp[a[i + 1] - 1], k + i * (r - r % a[i + 1] - a[i + 1]));
      mp[r % a[i + 1]] = max(mp[r % a[i + 1]], k + i * (r - r % a[i + 1]));
    }
  }
  long long ans = 0;
  for (map<long long, long long>::iterator it = mp.begin(); it != mp.end();
       it++)
    ans = max(ans, n * it->first + it->second);
  printf("%I64d\n", ans);
  return 0;
}
