#include <bits/stdc++.h>
using namespace std;
const int INF = 1000001000;
const long long INFL = 2000000000000001000;
int solve();
int main() {
  srand(2317);
  cout.precision(10);
  cout.setf(ios::fixed);
  int tn = 1;
  for (int i = 0; i < tn; ++i) solve();
}
const int maxn = 500001;
int a[maxn];
int gcd(int a, int b) {
  while (a && b)
    if (a >= b)
      a %= b;
    else
      b %= a;
  return a + b;
}
vector<int> lens[maxn];
vector<int> divs;
bool ok[maxn];
bool nicelen[maxn];
int blocks[maxn];
int solve() {
  int n;
  cin >> n;
  for (int i = 0; i < int(n); ++i) cin >> a[i];
  for (int s = int(1); s < int(n); ++s) {
    int g = gcd(s, n);
    if (g == s) divs.push_back(g);
    lens[g].push_back(s);
  }
  long long ans = 0;
  for (int s : divs) {
    fill(ok, ok + n, false);
    for (int rem = 0; rem < int(s); ++rem) {
      int best = 0;
      for (int i = rem; i < n; i += s) best = max(best, a[i]);
      for (int i = rem; i < n; i += s)
        if (a[i] == best) ok[i] = true;
    }
    int ptr = 0;
    while (ptr < n && ok[ptr]) ++ptr;
    if (ptr == n) {
      ans += (long long)((int)(lens[s]).size()) * n;
      continue;
    }
    assert(ptr < n);
    rotate(ok, ok + ptr, ok + n);
    assert(!ok[0]);
    vector<int> v;
    int total = 0;
    for (int i = 0; i < int(n); ++i) {
      if (!ok[i]) continue;
      ++total;
      if (!ok[i - 1])
        v.push_back(1);
      else
        v.back()++;
    }
    fill(blocks, blocks + n + 1, 0);
    for (auto x : v) {
      blocks[x]++;
    }
    int all = ((int)(v).size());
    fill(nicelen, nicelen + n, false);
    for (auto len : lens[s]) nicelen[len] = true;
    for (int len = int(1); len < int(n); ++len) {
      if (nicelen[len]) {
        ans += total;
      }
      total -= all;
      all -= blocks[len];
    }
  }
  cout << ans << '\n';
  return 0;
}
