AP or Not
Practice
3.4 (7 votes)
Sorting
Basic programming
Easy
Mathematics
Open
Approved
Mathamatics
Problem
52% Success 4206 Attempts 20 Points 5s Time Limit 256MB Memory 1024 KB Max Code

Bob and Khatu are best friends. One Bob asked Khatu to solve a problem. He gave him an array of integers and asked him to tell him if he can arrange elements in the array such that the array forms a special sequence.
A special sequence is a sequence in which every two consecutive elements have same difference.
Since Khatu is good at solving problems he solved it within 1 minute. Now its time for you to solve the problem.

Input:
First line of input contains number of test cases T. Each test case contains two lines. First line contains value of N, size of Array. Next line contains N elements separated by space.

Output:
For each test case print YES if it is possible to arrange elements of array such that array form a special sequence else print NO.

Constraints:
1 ≤ T ≤ 5
3 ≤ N ≤ 105
0 ≤ Ai ≤ 109

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
3 votes
Tags:
Ad-HocData StructuresOpenApprovedEasyMathamatics
Points:20
3 votes
Tags:
Basic MathNumber theoryAlgorithmsMath
Points:20
Tags:
MathPatterns