#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = mod * mod;
const long double eps = 1e-6;
const long double pi = acos(-1.0);
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  while (b) {
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}
vector<int> divisor(int x) {
  vector<int> ret;
  for (int i = 1; i <= 1000; i++) {
    if (x % i == 0) {
      ret.push_back(i);
      ret.push_back(x / i);
    }
  }
  sort(ret.begin(), ret.end());
  ret.erase(unique(ret.begin(), ret.end()), ret.end());
  return ret;
}
bool allsame(vector<int> &a) {
  for (int i = 0; i < (int)a.size() - 1; i++) {
    if (a[i] != a[i + 1]) return false;
  }
  return true;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  if (allsame(a)) {
    long long ans = (long long)n * (n - 1);
    cout << ans << endl;
    return;
  }
  vector<int> d = divisor(n);
  d.pop_back();
  long long ans = 0;
  for (int i = 0; i < d.size(); i++) {
    vector<int> non;
    int k = d[i];
    vector<int> ma(k, 0);
    for (int j = 0; j < n; j++) {
      ma[j % k] = max(ma[j % k], a[j]);
    }
    for (int j = 0; j < n; j++) {
      if (ma[j % k] != a[j]) non.push_back(j);
    }
    int sz = non.size();
    for (int j = 0; j < sz; j++) non.push_back(non[j] + n);
    int u = n / k;
    vector<bool> p(u, true);
    for (int j = 0; j < d.size(); j++) {
      if (u % d[j] || d[j] == 1) continue;
      for (int l = d[j]; l < u; l += d[j]) p[l] = false;
    }
    vector<int> rc(u, 0);
    for (int j = 0; j < u - 1; j++) {
      rc[j + 1] += rc[j];
      if (p[j + 1]) rc[j + 1]++;
    }
    if (non.empty()) {
      ans += (long long)n * rc[u - 1];
      continue;
    }
    int le = 0;
    for (int j = 0; j < n; j++) {
      if (j > non[le]) le++;
      if (j == non[le]) continue;
      int dif = non[le] - j;
      dif /= k;
      ans += rc[dif];
    }
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
