#include <bits/stdc++.h>
using namespace std;
long long n, i, x, y, ans, a[200010];
map<long long, long long> f;
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  f[a[1] - 1] = 0;
  for (i = 2; i <= n; i++) {
    for (map<long long, long long>::iterator j = f.lower_bound(a[i]);
         j != f.end(); f.erase(j++)) {
      x = j->first;
      y = j->second;
      f[x % a[i]] = max(f[x % a[i]], y + (i - 1) * (x - x % a[i]));
      f[a[i] - 1] =
          max(f[a[i] - 1], y + (i - 1) * ((x + 1) / a[i] * a[i] - a[i]));
    }
  }
  for (map<long long, long long>::iterator j = f.begin(); j != f.end(); j++) {
    x = j->first;
    y = j->second;
    ans = max(ans, x * n + y);
  }
  printf("%lld", ans);
}
