Hidden Number
Practice
5 (2 votes)
Mathematics
Easy
Mathematics
Mathamatics
Problem
52% Success 6752 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array $$A$$ of $$N$$ integers. Now there is another integer $$X$$ which is unknown but you know its properties. The properties of the unknown number are:

$$1$$. It is an integer.

$$2$$. If you subtract all the elements of the array $$A$$ individually from the number $$X$$ and add all the differences then it adds to $$0$$.

Your goal is to find the number $$X$$.

Input
The first line contains an integer $$T$$ denoting the total number of test cases.
The first line of each test case contains an integer $$N$$ as input.
Next line of each test case contains $$N$$ space separated integers.

Output
In the output you need to print the number $$X$$ if it exists or else you need to print $$-1$$. 

Constraints
$$1 \le T \le 10$$
$$1 \le N \le 10^5$$
$$1 \le A[i] \le 10^9$$

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
Tags:
ImplementationEasyMath
Points:20
17 votes
Tags:
EasyBasic MathMathematicsMathematics
Points:20
1 votes
Tags:
Basic MathBitwise XOR