#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;
}
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;
  for (int64_t d = 1; d * d <= n; ++d)
    if (n % d == 0) {
      divisorsOfN.push_back(d);
      if (n / d > d && d != 1) divisorsOfN.push_back(n / d);
    }
  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;
}
