#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool isprime[1000005];
int prime[1000005], prinum;
void getprime() {
  isprime[0] = 1;
  isprime[1] = 1;
  for (int i = 2; i < 1000005; i++) {
    if (!isprime[i]) {
      prime[prinum++] = i;
    }
    for (int j = 0; j < prinum; j++) {
      if (i * prime[j] > 1000005) break;
      isprime[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int num[200005];
int n;
bool mn[205][200005];
int sum[205][200005];
vector<int> vec[205];
int fac[205];
map<int, int> mp;
int facnum;
int main() {
  getprime();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &num[i]);
  for (int i = 1; i < n; i++) {
    if (n % i == 0) {
      fac[facnum] = i;
      mp[i] = facnum++;
    }
  }
  for (int i = 0; i < facnum; i++) {
    for (int k = 0; k < fac[i]; k++) {
      int tmp = 0;
      for (int j = k; j < n; j += fac[i]) tmp = max(tmp, num[j]);
      for (int j = k; j < n; j += fac[i]) {
        if (num[j] == tmp) mn[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < facnum; i++) {
    int pos = 0;
    for (; pos < n; pos++) {
      if (mn[i][pos] == 0) break;
    }
    if (pos == n)
      continue;
    else {
      for (int t = 0; t < n; t++) {
        if (mn[i][(pos + t) % n] == 1) {
          int len = 0;
          while (mn[i][(pos + t + len) % n] == 1) {
            len++;
          }
          vec[i].push_back(len);
          t += len;
        }
      }
    }
  }
  for (int i = 0; i < facnum; i++) {
    int siz = vec[i].size();
    if (siz == 0)
      continue;
    else {
      sort(vec[i].begin(), vec[i].end());
      sum[i][0] = vec[i][0];
      for (int j = 1; j < siz; j++) {
        sum[i][j] = vec[i][j] + sum[i][j - 1];
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    int gd = gcd(i, n);
    int siz = vec[mp[gd]].size();
    if (siz == 0)
      ans = ans + n;
    else {
      int pos = lower_bound(vec[mp[gd]].begin(), vec[mp[gd]].end(), i) -
                vec[mp[gd]].begin();
      ans = ans + sum[mp[gd]][siz - 1] - (pos == 0 ? 0 : sum[mp[gd]][pos - 1]) -
            (long long)(siz - pos) * (i - 1);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
