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) be the minimal square number strictly greater than x , and g(x) be the maximal square number not strictly less than x . For example, f(1)=f(2)=g(4)=g(8)=4 .
"not strictly less than" means less than or equal to.
A positive integer x is cute if x−g(x)<f(x)−x . For example, 1,5,11 are cute integers, while 3,8,15 are not.
Ran gives you an array a of length n . She wants you to find the smallest non-negative integer k such that ai+k is a cute number for any element of a .
输入格式
The first line contains one integer n ( 1≤n≤106 ) — the length of a .
The second line contains n intergers a1,a2,…,an ( 1≤a1≤a2≤…≤an≤2⋅106 ) — the array a .
输出格式
Print a single interger k — 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:
3 is not cute integer, so k=0 .
2,4,9,11 are cute integers, so k=1 .