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.
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStreamReader;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        private int gcd(int a, int b) {
            if (b == 0) {
                return a;
            }
            return gcd(b, a % b);
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }

            int[] aCopy = new int[a.length * 2];
            for (int i = 0; i < 2 * n; ++i) {
                aCopy[i] = a[i % n];
            }
            a = aCopy;

            int cont = 0;
            for (int i = 1; i < n; ++i) {
                if (n % i == 0) {
                    ++cont;
                }
            }

            int[] numbers = new int[cont];
            cont = 0;
            for (int i = 1; i < n; ++i) {
                if (n % i == 0) {
                    numbers[cont++] = i;
                }
            }

            int[] g = new int[n + 1];
            for (int i = 1; i <= n; ++i) {
                g[i] = gcd(n, i);
            }

            long answer = 0;
            int[] gcdCount = new int[n + 1];
            int[] maxValue = new int[n];
            for (int j = 0; j < cont; ++j) {
                for (int i = 0; i < numbers[j]; ++i) {
                    maxValue[i] = 0;
                }

                gcdCount[0] = 0;
                for (int i = 1; i <= n; ++i) {
                    gcdCount[i] = gcdCount[i - 1];
                    if (g[i] == numbers[j]) {
                        ++gcdCount[i];
                    }
                }

                for (int i = 0; i < n; ++i) {
                    maxValue[i % numbers[j]] = Math.max(maxValue[i % numbers[j]], a[i]);
                }

                int nextBlock = n;
                while (nextBlock < 2 * n && maxValue[nextBlock % numbers[j]] <= a[nextBlock]) {
                    ++nextBlock;
                }

                for (int i = n - 1; i >= 0; --i) {
                    if (maxValue[i % numbers[j]] > a[i]) {
                        nextBlock = i;
                    }

                    answer += gcdCount[Math.min(nextBlock - i, n)];
                }

//            System.err.println("num = " + numbers[j] + ", answer = " + answer);
            }

            out.println(answer);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    throw new UnknownError();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

