#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
int tank[MAXN];
int N;
int q[MAXN], qn, bg;
int solve(int id) {
  int cur = qn - 1, ret = 1;
  while (q[cur] - tank[q[cur]] > id - N) {
    ++ret;
    int tmp = cur;
    for (int i = tmp - 1; i >= bg && q[i] >= q[tmp] - tank[q[tmp]]; cur = i--)
      ;
  }
  return ret;
}
int main() {
  while (cin >> N) {
    for (int i = 0; i < N; ++i) {
      scanf("%d", &tank[i]);
      tank[i + N] = tank[i];
    }
    for (int i = 0; i < N; ++i) {
      while (qn && i - tank[i] <= q[qn - 1] - tank[q[qn - 1]]) --qn;
      q[qn++] = i;
    }
    long long ans = 0;
    for (int i = N; i < 2 * N; ++i) {
      ans += solve(i);
      if (q[bg] == i - N) ++bg;
      while (qn > bg && i - tank[i] <= q[qn - 1] - tank[q[qn - 1]]) --qn;
      q[qn++] = i;
    }
    cout << ans << endl;
  }
  return 0;
}
