 Timer is Running

Largest number that is not a perfect square (Deleted)
##### Submissions: 37   Accuracy: 37.83%   Difficulty: Basic   Marks: 1

Given an array of N integers, you need to find the maximum element among them that is not a perfect square. If all the array elements are perfect squares, you should print -1.

Input:
The first line of the input contains a single integer T, denoting the number of test cases. Then T test cases follow. Each test case contains two lines of input:-
The size of the array N
The elements of the array separated by spaces.

Output:
For each testcase, print the maximum element of the array that is not a perfect square. If no such element exists, print -1.

Constraints:
1<=T<=107
1<=N<=10000
1<=A[i]<=10000

Example:

Input:
2
6
16 20 25 2 3 10
6
0 1 4 9 16 25

Output:
20
-1

Explanation:
For testcase 1: 20 is the greatest number in the array that is not a perfect square.
For testcase 2: All elements are perfect squares, hence we print -1.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ankit Sharma
Author: Soul_xhacker

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.