#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int N;
  scanf("%d", &N);
  vector<int> a(N);
  for (int i = 0; i < (int)(N); ++i) scanf("%d", &a[i]);
  vector<int> divs;
  vector<vector<int> > byd;
  vector<vector<int> > dd;
  map<int, int> en;
  for (int k = 1; k <= (int)(N); ++k) {
    if (N % k) continue;
    en[k] = divs.size();
    divs.push_back(k);
    vector<int> d(N);
    for (int i = 0; i < (int)(k); ++i) {
      int mx = 0;
      for (int j = 0; j < (int)(N / k); ++j) uax(mx, a[i + j * k]);
      for (int j = 0; j < (int)(N / k); ++j)
        if (a[i + j * k] == mx) d[i + j * k] = 1;
    }
    dd.push_back(d);
  }
  byd.resize(divs.size());
  for (int k = 1; k <= (int)(N - 1); ++k) byd[en[gcd(k, N)]].push_back(k);
  long long ans = 0;
  for (int i = 0; i < (int)(divs.size()); ++i) {
    if (*min_element((dd[i]).begin(), (dd[i]).end()) == 1) {
      ans += 1LL * N * byd[i].size();
      continue;
    }
    vector<int> res(N + 1);
    int l = 0;
    int q = 0;
    for (int j = 1; j <= (int)(N); ++j) {
      if (l < byd[i].size() && byd[i][l] == j) ++q, ++l;
      res[j] = q;
    }
    if (dd[i][0]) {
      l = 1;
      for (int x = (int)(N)-1; x >= 0; --x) {
        if (dd[i][x])
          ++l;
        else
          break;
      }
    } else
      l = 0;
    for (int j = 0; j < (int)(N); ++j) {
      ans += res[l];
      if (!dd[i][(j + 1) % N])
        l = 0;
      else
        ++l;
    }
  }
  cout << ans << '\n';
  return 0;
}
