CF1687D.Cute number

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Ran is especially skilled in computation and mathematics. It is said that she can do unimaginable calculation work in an instant.

—Perfect Memento in Strict Sense

Ran Yakumo is a cute girl who loves creating cute Maths problems.

Let f(x)f(x) be the minimal square number strictly greater than xx , and g(x)g(x) be the maximal square number not strictly less than xx . For example, f(1)=f(2)=g(4)=g(8)=4f(1)=f(2)=g(4)=g(8)=4 .

"not strictly less than" means less than or equal to.

A positive integer xx is cute if xg(x)<f(x)xx-g(x)<f(x)-x . For example, 1,5,111,5,11 are cute integers, while 3,8,153,8,15 are not.

Ran gives you an array aa of length nn . She wants you to find the smallest non-negative integer kk such that ai+ka_i + k is a cute number for any element of aa .

输入格式

The first line contains one integer nn ( 1n1061 \leq n \leq 10^6 ) — the length of aa .

The second line contains nn intergers a1,a2,,ana_1,a_2,\ldots,a_n ( 1a1a2an21061 \leq a_1 \leq a_2 \leq \ldots \leq a_n \leq 2\cdot 10^6 ) — the array aa .

输出格式

Print a single interger kk — the answer.

输入输出样例

  • 输入#1

    4
    1 3 8 10

    输出#1

    1
  • 输入#2

    5
    2 3 8 9 11

    输出#2

    8
  • 输入#3

    8
    1 2 3 4 5 6 7 8

    输出#3

    48

说明/提示

Test case 1:

33 is not cute integer, so k0k\ne 0 .

2,4,9,112,4,9,11 are cute integers, so k=1k=1 .

首页