You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≤ l < n, 1 ≤ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of array a, starting with position l.

A periodic subarray (l, s) is superior, if when attaching it to the array a, starting from index l, any element of the subarray is larger than or equal to the corresponding element of array a. An example of attaching is given on the figure (top — infinite array a, bottom — its periodic subarray (l, s)):

<image>

Find the number of distinct pairs (l, s), corresponding to the superior periodic arrays.

Input

The first line contains number n (1 ≤ n ≤ 2·105). The second line contains n numbers a0, a1, ..., an - 1 (1 ≤ ai ≤ 106), separated by a space.

Output

Print a single integer — the sought number of pairs.

Examples

Input

4
7 1 2 3


Output

2


Input

2
2 1


Output

1


Input

3
1 1 1


Output

6

Note

In the first sample the superior subarrays are (0, 1) and (3, 2).

Subarray (0, 1) is superior, as a0 ≥ a0, a0 ≥ a1, a0 ≥ a2, a0 ≥ a3, a0 ≥ a0, ...

Subarray (3, 2) is superior a3 ≥ a3, a0 ≥ a0, a3 ≥ a1, a0 ≥ a2, a3 ≥ a3, ...

In the third sample any pair of (l, s) corresponds to a superior subarray as all the elements of an array are distinct.
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7FFFFFFF;
const long long infll = 1ll * inf * inf;
const double eps = 1e-9;
const double pi = acos(-1.0);
int gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }
inline bool read(int& val) { return scanf("%d", &val) != -1; }
inline bool read(unsigned int& val) { return scanf("%d", &val) != -1; }
inline bool read(long long& val) { return scanf("%I64d", &val) != -1; }
inline bool read(float& val) { return scanf("%f", &val) != -1; }
inline bool read(double& val) { return scanf("%lf", &val) != -1; }
inline bool read(char* val) { return scanf("%s", val) != -1; }
inline bool read(char& val) { return scanf("%c", &val) != -1; }
template <class T1, class T2>
inline bool read(T1& a, T2& b) {
  return read(a) && read(b);
}
template <class T1, class T2, class T3>
inline bool read(T1& a, T2& b, T3& c) {
  return read(a) && read(b) && read(c);
}
template <class T1, class T2, class T3, class T4>
inline bool read(T1& a, T2& b, T3& c, T4& d) {
  return read(a) && read(b) && read(c) && read(d);
}
template <class T1, class T2, class T3, class T4, class T5>
inline bool read(T1& a, T2& b, T3& c, T4& d, T5& e) {
  return read(a) && read(b) && read(c) && read(d) && read(e);
}
using namespace std;
const int N = 444444;
int a[N];
int m[N];
bool ok[N];
vector<int> gcdn[N];
int main() {
  int n;
  read(n);
  for (int i = 1, _ = n; i < _; i++) gcdn[gcd(i, n)].push_back(i);
  for (int i = 0, _ = n; i < _; i++) read(a[i]), a[n + i] = a[i];
  long long ans = 0;
  for (int i = 1, _ = n; i < _; i++)
    if (n % i == 0) {
      for (int j = 0, _ = i; j < _; j++) m[j] = 0;
      for (int j = 0, _ = 2 * n; j < _; j++) ok[j] = false;
      for (int j = 0, _ = i; j < _; j++)
        for (int k = j, _ = n, _s = i; k < _; k += _s) m[j] = max(m[j], a[k]);
      for (int j = 0, _ = i; j < _; j++)
        for (int k = j, _ = n, _s = i; k < _; k += _s)
          if (a[k] == m[j]) ok[k + n] = ok[k] = true;
      int p = 0;
      for (int i = 0, _ = n; i < _; i++)
        if (!ok[i]) {
          p = i;
          break;
        }
      int q = p + n;
      while (p < q) {
        int j = p;
        while (j < q && ok[j]) j++;
        int m = j - p;
        for (int k = 0, _ = gcdn[i].size(); k < _; k++) {
          if (gcdn[i][k] > m) break;
          if (m == n)
            ans += m;
          else
            ans += m - gcdn[i][k] + 1;
        }
        p = j + 1;
      }
    }
  printf("%I64d\n", ans);
  return 0;
}
