Missing element of AP
Submissions: 9107   Accuracy:


  Difficulty: Easy   Marks: 2

Find the missing element from  an ordered array A[ ], consisting of N elements representing an Arithmetic Progression (AP) .

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. 
The first line of each test case contains an integer N, where N is the size of the array A[ ].
The second line of each test case contains N space separated integers of an Arithmetic Progression denoting elements of the array A[ ].


Note: The series should have a missing element in between a perfect A.P. with no missing element will not be considered.

Print out the missing element. 


1 <= T <= 100
2 <= N <= 10
-50 <= A[i] <=50


Examples :


2 10 14 

-28 -21 -7 0 

9 12 15 21 24

Output : 

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

Author: Rohan Malhotra

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.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.