#include <bits/stdc++.h>
using namespace std;
int INT_MAX_VAL = (int)0x3F3F3F3F;
int INT_MIN_VAL = (int)-0x3F3F3F3F;
long long LONG_MAX_VAL = (long long)0x3F3F3F3F3F3F3F3F;
long long LONG_MIN_VAL = (long long)-0x3F3F3F3F3F3F3F3F;
int n;
int as[500006];
int far[500006];
int cnt_calc[500006 / 2];
int mx[500006];
int gcd_calc[500006];
int gcdr(int a, int b) { return a ? gcdr(b % a, a) : b; }
int gcd(int a) {
  if (gcd_calc[a] != 0) return gcd_calc[a];
  return gcd_calc[a] = gcdr(a, n);
}
bool g_set[500006];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long(i) = 0LL; (i) < (n); (i)++) cin >> as[i];
  for (long long(i) = 0LL; (i) < (n); (i)++) as[i + n] = as[i];
  vector<long long> gs;
  for (int i = 1; i < n; ++i) {
    long long g = gcd(i);
    if (!g_set[g]) gs.push_back(g);
    g_set[g] = true;
  }
  long long ans = 0;
  for (int j = 0; j < gs.size(); ++j) {
    int g = gs[j];
    memset(mx, 0, sizeof(int) * 500006);
    cnt_calc[0] = 0;
    for (int i = 1; i < n; ++i) cnt_calc[i] = cnt_calc[i - 1] + (g == gcd(i));
    for (int i = 2 * n - 1; i >= 0; --i) {
      if (as[i] >= mx[i % g])
        far[i] = true;
      else
        far[i] = false;
      mx[i % g] = max(mx[i % g], as[i]);
    }
    int cnt = 0;
    for (int i = 2 * n - 1; i >= 0; --i) {
      if (far[i])
        cnt = min(n - 1, cnt + 1);
      else
        cnt = 0;
      if (i < n) {
        ans += cnt_calc[cnt];
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
