#K70692. Smallest Periodic Sequence

    ID: 33365 Type: Default 1000ms 256MiB

Smallest Periodic Sequence

Smallest Periodic Sequence

Given a sequence of integers, determine the smallest positive integer k such that the sequence is k-periodic. A sequence is said to be k-periodic if it can be constructed by repeating a subsequence of length k exactly. In other words, there exists a sequence t of length k such that the original sequence equals t repeated some number of times, i.e., \( s = t^m \) for some integer \( m \ge 1 \).

Your task is to compute and output the smallest such k for the given sequence.

inputFormat

The first line contains a single integer \( n \) (the number of elements in the sequence). The second line contains \( n \) space-separated integers representing the sequence.

outputFormat

Output a single integer, which is the smallest \( k \) for which the sequence is \( k \)-periodic.

## sample
4
1 2 1 2
2