#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
long long n;
long long a[MAXN], f[MAXN];
int main() {
  scanf("%I64d", &n);
  for (long long i = n; i >= 1; --i) {
    scanf("%I64d", &a[i]);
    if (i != n) a[i] = min(a[i], a[i + 1]);
  }
  a[0] = 1;
  long long j;
  for (long long i = 1; i <= n; ++i) {
    long long las = 0;
    for (long long k = a[i]; k; k %= a[j]) {
      j = lower_bound(a + 1, a + n + 1, k) - a - 1;
      f[i] = max(f[i], f[j] + (n - j) * (k / a[j] - 1) * a[j] + las);
      las += (n - j) * (k / a[j]) * a[j];
    }
  }
  printf("%I64d\n", f[n]);
  return 0;
}
