#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, w = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * w;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const long long maxn = 1e6 + 5;
const long long mod = 998244353;
const long long inf = 0x3f3f3f3f3f3f3f;
inline long long min(long long x, long long y) { return x < y ? x : y; }
inline long long max(long long x, long long y) { return x > y ? x : y; }
long long n, ans, a[maxn], f[maxn], g[maxn], cnt[maxn];
bool buc[maxn];
inline long long gcd(long long a, long long b) {
  return !b ? a : gcd(b, a % b);
}
signed main(void) {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read(), a[i + n] = a[i];
  for (long long d = 1; d < n; d++) {
    if (n % d == 0) {
      memset(buc, 0, sizeof(buc));
      for (long long k = 0; k < d; k++) {
        g[k] = 0;
        for (long long i = k; i < (n << 1); i += d) g[k] = max(g[k], a[i]);
        for (long long i = k; i < (n << 1); i += d)
          if (g[k] == a[i]) buc[i] = 1;
      }
      f[0] = buc[0];
      for (long long i = 1; i < (n << 1); i++) {
        if (buc[i])
          f[i] = f[i - 1] + 1;
        else
          f[i] = 0;
        f[i] = min(f[i], n - 1);
      }
      cnt[0] = 0;
      for (long long i = 1; i < (n / d); i++)
        cnt[i] = cnt[i - 1] + (gcd(i, n / d) == 1);
      for (long long i = n; i < (n << 1); i++) ans += cnt[f[i] / d];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
