#include <bits/stdc++.h>
int a[423456];
int first[423456];
int next[423456];
int value[423456];
int sz = 0;
int b[423456];
int is_max[423456];
int make_list(int start) {
  int res = 0;
  while (start != -1) {
    b[res] = value[start];
    start = next[start];
    res++;
  }
  return res;
}
int gcd(int x, int y) { return x == 0 ? y : gcd(y % x, x); }
void add(int x, int y) {
  int tmp = first[x];
  first[x] = sz;
  value[sz] = y;
  next[sz] = tmp;
  sz++;
}
int main() {
  int n, i, go, value;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i <= n; i++) {
    first[i] = -1;
  }
  for (go = 1; go < n; go++) {
    int f = gcd(go, n);
    add(f, go);
  }
  long long result = 0;
  for (value = 1; value < n; value++) {
    int cnt = make_list(first[value]);
    if (cnt == 0) {
      continue;
    }
    int j;
    for (i = 0, j = cnt - 1; i < j; i++, j--) {
      int tmp = b[i];
      b[i] = b[j];
      b[j] = tmp;
    }
    int start;
    for (start = 0; start < value; start++) {
      int ma = 0;
      int cur;
      for (cur = start; cur < n; cur += value) {
        if (a[cur] > ma) ma = a[cur];
      }
      for (cur = start; cur < n; cur += value) {
        is_max[cur + n] = is_max[cur] = (a[cur] == ma);
      }
    }
    int now_len = 0;
    for (i = n; i < 2 * n; i++) {
      if (is_max[i]) {
        now_len++;
      } else {
        break;
      }
    }
    int cur_it = 0;
    for (start = n - 1; start >= 0; start--) {
      if (is_max[start]) {
        now_len++;
      } else {
        now_len = 0;
      }
      while (cur_it < cnt && b[cur_it] <= now_len) cur_it++;
      while (cur_it > 0 && b[cur_it - 1] > now_len) cur_it--;
      result += cur_it;
    }
  }
  printf("%I64d\n", result);
  return 0;
}
