#K75972. Find Repeating Bell Strike Pattern

    ID: 34538 Type: Default 1000ms 256MiB

Find Repeating Bell Strike Pattern

Find Repeating Bell Strike Pattern

You are given a series of bell strikes recorded over a number of consecutive hours. The bell strikes may form a repeating pattern. Your task is to determine the number of hours after which the strike pattern repeats.

The input consists of an integer n representing the number of recorded bell strikes followed by n integers that describe the sequence of bell strikes. A valid repeating pattern is defined as a contiguous subsequence from the start that, when repeated, exactly forms the entire sequence. If no such pattern exists, output -1.

Note: If the total number of strikes is 1, the pattern does not count as repeating, so the answer should be -1.

For example, if the input sequence is [3, 5, 3, 5, 3, 5], the repeating pattern is [3, 5] and the answer is 2.

inputFormat

The first line of input contains an integer n (the number of recorded bell strikes).

The second line contains n space-separated integers denoting the bell strikes.

outputFormat

Output a single integer indicating the number of hours after which the pattern repeats. If the sequence does not have a repeating pattern, output -1.

## sample
6
3 5 3 5 3 5
2