#include <bits/stdc++.h>
using namespace std;
int n;
long long a[200005];
map<long long, long long> mp;
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%lld", &a[i]);
  mp.insert(pair<long long, long long>(a[1], 0));
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    auto j = mp.upper_bound(a[i + 1]);
    for (; j != mp.end();) {
      long long &f0 = mp[a[i + 1]];
      f0 = max(f0, j->second + (j->first / a[i + 1] - 1) * a[i + 1] * i);
      if (j->first % (a[i + 1])) {
        long long &f1 = mp[j->first % a[i + 1]];
        f1 = max(f1, j->second + j->first / a[i + 1] * a[i + 1] * i);
      }
      mp.erase(j++);
    }
  }
  long long ans = 0;
  for (auto i : mp) ans = max(ans, n * i.first + i.second - n);
  printf("%lld\n", ans);
}
