#GL0000156. Chia mảng thành những đoạn bằng nhau (Partitioning the Array)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chia mảng thành những đoạn bằng nhau (Partitioning the Array)
Partitioning the Array
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Allen has an array . For each positive divisor of , divide the array into consecutive, non-overlapping blocks of length .
Allen earns one point for if there exists an integer such that, after replacing every element by its remainder modulo , all blocks become identical at every corresponding position. Determine how many values of earn a point. When , there is only one block and the condition is automatically satisfied.
Input
The first line contains . The second line contains the integers .
Output
Print the number of positive divisors of satisfying the condition.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
4
1 2 1 4
Output
2
Explanation
For , the blocks and both become modulo . For , there is only one block. For , the difference makes every modulus at least impossible. Thus the answer is .