#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * 1e5 + 100;
long long n, a[N], t[N], b[N], w, sum[N], ans;
vector<long long> g[N];
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
inline long long read() {
  long long f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
void solve(long long d) {
  memset(t, 0, (n + 10) * sizeof(long long));
  for (long long i = 0; i < d; i++) {
    long long MAX = 0;
    for (long long j = i; j < n; j += d) MAX = max(MAX, a[j]);
    for (long long j = i; j < n; j += d)
      if (a[j] == MAX) t[j] = 1;
  }
  w = 0;
  for (long long i = 0; i < n;) {
    long long j = i;
    while (j < n && t[i] == t[j]) j++;
    if (t[i]) b[++w] = j - i;
    i = j;
  }
  if (b[1] == n) {
    for (long long i = 0; i < (long long)g[d].size(); i++) ans += n;
    return;
  }
  if (t[0] && t[n - 1]) b[1] += b[w--];
  sort(b + 1, b + 1 + w);
  sum[w + 1] = 0;
  for (long long i = w; i >= 1; i--) sum[i] = sum[i + 1] + b[i];
  for (long long i = 0, j = 1; i < (long long)g[d].size(); i++) {
    while (b[j] < g[d][i] && j <= w) j++;
    ans += sum[j] - (g[d][i] - 1) * (w - j + 1);
  }
}
signed main() {
  n = read();
  for (long long i = 0; i < n; i++) a[i] = read();
  for (long long i = 1; i < n; i++) g[gcd(i, n)].push_back(i);
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      solve(i);
      if (i * i != n) solve(n / i);
    }
  }
  printf("%lld\n", ans);
}
