#include <bits/stdc++.h>
long long n, a[1000005], ans;
std::map<long long, long long> DP;
long long read() {
  char c = getchar();
  long long ans = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans;
}
void Write(long long x) {
  if (x < 10)
    putchar(x ^ 48);
  else
    Write(x / 10), putchar((x % 10) ^ 48);
  return;
}
long long max(long long u, long long v) { return u > v ? u : v; }
long long min(long long u, long long v) { return u < v ? u : v; }
int main() {
  n = read();
  for (register long long i = 1; i <= n; i++) a[i] = read();
  DP[a[1] - 1] = 0;
  for (register long long i = 1; i < n; i++)
    for (auto it = DP.lower_bound(a[i + 1]); it != DP.end(); DP.erase(it++))
      DP[it->first % a[i + 1]] =
          max(DP[it->first % a[i + 1]],
              it->second + i * (it->first - it->first % a[i + 1])),
                           DP[a[i + 1] - 1] = max(
                               DP[a[i + 1] - 1],
                               it->second +
                                   i * ((it->first + 1) / a[i + 1] * a[i + 1] -
                                        a[i + 1]));
  for (auto it = DP.begin(); it != DP.end(); it++)
    ans = max(ans, it->first * n + it->second);
  Write(ans);
  return 0;
}
