#include <bits/stdc++.h>
using namespace std;
const int MAXN = 502400;
const int MAXM = 1 << 21;
const int INF = 1012345678;
int pos[MAXN];
struct SegTree {
  int N, tree[MAXM];
  int LEFT(int x) { return x << 1; }
  int RIGHT(int x) { return (x << 1) | 1; }
  void _init(int o, int s, int t) {
    tree[o] = INF;
    if (s == t) {
      pos[s] = o;
      return;
    }
    int mid = (s + t) >> 1;
    _init(LEFT(o), s, mid);
    _init(RIGHT(o), mid + 1, t);
  }
  void init(int N) {
    this->N = N;
    _init(1, 0, N - 1);
  }
  void _update(int o, int value) {
    tree[o] = value;
    while (o != 1) {
      o >>= 1;
      tree[o] = min(tree[LEFT(o)], tree[RIGHT(o)]);
    }
  }
  void update(int o, int value) { _update(pos[o], value); }
  int l, r;
  int _query(int o, int s, int t) {
    if (l <= s && t <= r) return tree[o];
    int mid = (s + t) >> 1;
    if (r <= mid) return _query(LEFT(o), s, mid);
    if (mid < l) return _query(RIGHT(o), mid + 1, t);
    return min(_query(LEFT(o), s, mid), _query(RIGHT(o), mid + 1, t));
  }
  int query(int l, int r) {
    this->l = l;
    this->r = r;
    return _query(1, 0, N - 1);
  }
};
const int MAXBIT = 21;
SegTree sg[MAXBIT];
int n, a[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int maxbit;
  for (int bit = 0;; bit++) {
    sg[bit].init(n);
    maxbit = bit;
    if (1 << bit > n) break;
  }
  for (int i = 0; i < n; i++) {
    sg[0].update(i, max(i - a[i], -n));
  }
  for (int bit = 0; bit < maxbit; bit++) {
    for (int i = 0; i < n; i++) {
      int minCurrent = sg[bit].tree[pos[i]], minNext;
      if (minCurrent < 0) {
        minNext =
            min(sg[bit].query(0, i), sg[bit].query(minCurrent + n, n - 1) - n);
      } else {
        minNext = sg[bit].query(minCurrent, i);
      }
      sg[bit + 1].update(i, max(minNext, -n));
    }
  }
  long long res = 0;
  {
    int j = 0, k = n - 1, bit, answer = 0;
    for (bit = 0; bit <= maxbit; bit++) {
      if (sg[bit].tree[pos[k]] + n <= j) break;
    }
    for (bit--; bit >= 0; bit--) {
      int nextK = sg[bit].query(k, n - 1);
      if (j < nextK) {
        answer |= 1 << bit;
        k = nextK;
      }
    }
    res += answer;
  }
  for (int i = 0; i < n - 1; i++) {
    int j = i + 1, k = i, bit, answer = 0;
    for (bit = 0; bit <= maxbit; bit++) {
      if (sg[bit].tree[pos[k]] + n <= j) break;
    }
    for (bit--; bit >= 0; bit--) {
      if (k < j) {
        int nextK = sg[bit].query(k, i);
        if (j < nextK + n) {
          answer |= 1 << bit;
          k = nextK < 0 ? nextK + n : nextK;
        }
      } else {
        int nextK = min(sg[bit].query(0, i) + n, sg[bit].query(k, n - 1));
        if (j < nextK) {
          answer |= 1 << bit;
          k = nextK;
        }
      }
    }
    res += answer;
  }
  printf("%I64d\n", res + n);
  return 0;
}
