Aesthetics in poetry Gym - 101879B

博客介绍了葡萄牙诗人卡蒙斯及其作品,提到Carlitos在研究其诗歌美学,定义了诗歌的K - 优雅度概念。给出了计算诗歌最小优雅度的输入输出要求,包括输入诗歌行数及每行大小,输出最小的K值使诗歌为K - 优雅,若不存在则输出 - 1。

One of the greatest poets in Portuguese language was Luiz Vaz de Camões, born in Lisbon circa 1524. Camões works are fundamental reading for high school students in countries such as Brazil or Portugal. Many consider his 5- and 7-syllable poems and his sonnets (with 14 verses) to be the most important lyrical work in Portuguese of all time.

Camões was a visionary in his own time. His work has been studied from many aspects: historical, cultural, symbolical, and so on. Carlitos "the efficient" Nunes is studying aesthetics in Camões' poetry. He is especially interested in a metric based on the size of the verses of a poem. We define this metric as follows. Suppose we have a poem made of NN verses. We say that the poem is KK-elegant if K>1K>1, NN is a multiple of KK and, moreover, there are exactly N/KN/K verses whose sizes, when divided by KK, have remainders equal to ii, for i=0,1,…,K−1i=0,1,…,K−1. Note that a single poem may be KK-elegant for several distinct values of KK.

Carlitos already processed the data from poems by Camões and now he needs your help to determine the smallest elegance in each of the poems.

Input

The input has two lines. The first line has an integer NN, the number of verses in the poem. In the second line you are given NN integers, say ℓ1,ℓ2,…,ℓNℓ1,ℓ2,…,ℓN, such that ℓiℓirepresents the size of the iith verse of the poem.

Constraints

  • 1≤N≤2⋅1031≤N≤2⋅103
  • 1≤ℓi≤1091≤ℓi≤109

Output

A single integer KK, the smallest integer such that the poem is KK-elegant. If no such integer exists, print "-1".

Examples

Input

6
3 6 1 7 8 14

Output

2

Input

5
17 21 14 35 13

Output

5

Note

In the first case, if K=2K=2, then 6,86,8 and 1414 (respectively, 33, 11 and 77) have remainder 00 (respectively, remainder 11) when divided by KK.

 

#include <bits/stdc++.h>
using namespace std;
int a[2005], num[2005];
int main()
{
    int n, m, i, j, k;
    scanf("%d", &n);
    for(i = 1; i <= n; i++)scanf("%d", &a[i]);
    for(i = 2; i <= n; i++)
    {
        if(n % i != 0)continue;
        memset(num, 0, sizeof(num));
        for(j = 1; j <= n; j++)
        {
            num[a[j] % i]++;
            if(num[a[j] % i] > n / i)break;
        }
        if(j == n + 1)
        {
            break;
        }
    }
    if(i == n + 1)printf("-1\n");
    else printf("%d\n", i);
    return 0;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值