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;
namespace mainns {
template <typename T>
void relaxMax(T& relaxWhat, const T& relaxBy) {
  relaxWhat = max(relaxWhat, relaxBy);
}
template <typename T>
void relaxMin(T& relaxWhat, const T& relaxBy) {
  relaxWhat = min(relaxWhat, relaxBy);
}
template <typename T>
int64_t sgn(T val) {
  return (T(0) < val) - (val < T(0));
}
namespace {
inline uint64_t gcdInternal(uint64_t a, uint64_t b) {
  if (b == 0) return a;
  return gcdInternal(b, a % b);
}
inline uint64_t gcdDecompositionInternal(uint64_t a, uint64_t b, int64_t& x,
                                         int64_t& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int64_t xx, yy;
  auto gcd = gcdDecompositionInternal(b, a % b, xx, yy);
  x = yy;
  y = xx - (a / b) * yy;
  return gcd;
}
}  // namespace
inline uint64_t greatestCommonDivisor(int64_t a, int64_t b) {
  a *= sgn(a);
  b *= sgn(b);
  if (a < b) std::swap(a, b);
  return gcdInternal(a, b);
}
inline uint64_t gcdDecomposition(int64_t a, int64_t b, int64_t& x, int64_t& y) {
  auto aUnsigned = a * sgn(a);
  auto bUnsigned = b * sgn(b);
  auto gcd = (aUnsigned < bUnsigned)
                 ? gcdDecompositionInternal(aUnsigned, bUnsigned, x, y)
                 : gcdDecompositionInternal(bUnsigned, aUnsigned, y, x);
  x *= sgn(a);
  y *= sgn(b);
  return gcd;
}
inline std::vector<int64_t> getDivisorsOf(int64_t n) {
  std::vector<int64_t> divisorsSmallerOrEqualSqrtOfN, divisorsBiggerSqrtOfN;
  for (int64_t d = 1; d * d <= n; ++d) {
    if (n % d == 0) {
      divisorsSmallerOrEqualSqrtOfN.push_back(d);
      if (d * d < n) divisorsBiggerSqrtOfN.push_back(n / d);
    }
  }
  std::copy(divisorsBiggerSqrtOfN.rbegin(), divisorsBiggerSqrtOfN.rend(),
            std::back_inserter(divisorsSmallerOrEqualSqrtOfN));
  return divisorsSmallerOrEqualSqrtOfN;
}
class Solver582C {
 public:
  void run();
};
void Solver582C::run() {
  int64_t n;
  cin >> n;
  valarray<int64_t> numbers(n);
  for (auto& elt : numbers) cin >> elt;
  if (n == 1) {
    cout << 0;
    return;
  }
  vector<int64_t> divisorsOfN = getDivisorsOf(n);
  divisorsOfN.pop_back();
  int64_t ans = 0;
  for (auto& d : divisorsOfN) {
    vector<int64_t> maximums(d);
    for (int64_t i = 0; i < d; ++i)
      maximums[i] = valarray<int64_t>(numbers[slice(i, n / d, d)]).max();
    vector<int64_t> consequentMaximumsLengths;
    bool onConsequentMaximum = false;
    for (int64_t i = 0; i < n; ++i) {
      if (numbers[i] == maximums[i % d]) {
        if (onConsequentMaximum)
          ++consequentMaximumsLengths.back();
        else {
          consequentMaximumsLengths.push_back(1);
          onConsequentMaximum = true;
        }
      } else
        onConsequentMaximum = false;
    }
    if (onConsequentMaximum && numbers[0] == maximums[0] &&
        consequentMaximumsLengths.size() > 1) {
      consequentMaximumsLengths.front() += consequentMaximumsLengths.back();
      consequentMaximumsLengths.pop_back();
    }
    for (auto l : consequentMaximumsLengths)
      for (int64_t multiplier = 1; d * multiplier <= l; ++multiplier) {
        if (greatestCommonDivisor(n / d, multiplier) > 1) continue;
        if (l == n)
          ans += l;
        else
          ans += l - d * multiplier + 1;
      }
  }
  cout << ans;
}
}  // namespace mainns
using CurrentSolver = mainns::Solver582C;
int main() {
  ios::sync_with_stdio(false);
  CurrentSolver().run();
  return 0;
}
