#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n;
long long a[N], ans;
map<long long, long long> dp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  dp[a[1] - 1] = 0;
  for (int i = 1; i < n; i++) {
    for (map<long long, long long>::iterator it = dp.lower_bound(a[i + 1]);
         it != dp.end(); dp.erase(it++)) {
      long long key = it->first, val = it->second;
      dp[key % a[i + 1]] =
          max(dp[key % a[i + 1]], val + (key - key % a[i + 1]) * i);
      dp[a[i + 1] - 1] =
          max(dp[a[i + 1] - 1],
              val + ((key + 1) / a[i + 1] * a[i + 1] - a[i + 1]) * i);
    }
  }
  for (map<long long, long long>::iterator it = dp.begin(); it != dp.end();
       it++) {
    long long key = it->first, val = it->second;
    ans = max(ans, key * n + val);
  }
  printf("%lld\n", ans);
  return 0;
}
