Verify Cyclic Difference Sets A cyclic difference set is a set of positive integers with a unique property:


Let n be the largest integer in the set.
Let r be any integer (not necessarily in the set) greater than 0 but less than or equal to n/2.
Let k be the number of solutions to (b - a) % n = r where a and b are any members of the set.  Each solution is an ordered pair (a,b).  (Also note that this version of modulo makes negative numbers positive by adding n to it, unlike the implementations in many languages.)
Finally, if and only if this is a cyclic difference set, the value of k does not depend on your choice of r.  That is, all values of r give the same number of solutions to the above congruence.


This can be illustrated with the following example:

Cyclic difference set: {4,5,6,8,9,11}
0 &lt; r &lt;= 11/2, so r = 1,2,3,4,5
r=1: (4,5) (5,6) (8,9)
r=2: (4,6) (6,8) (9,11)
r=3: (5,8) (6,9) (8,11)
r=4: (4,8) (5,9) (11,4)  since (4-11)%11=(-7)%11=4
r=5: (4,9) (6,11) (11,5)


Each value of r has the same number of solutions, 3 in this case, so this is a cyclic difference set.

Input

Input will be a list of positive integers.  Since this is a set property,  assume that input is not sorted.  You can assume that n is at least 2, although k may be zero.

Output

Your program/function should output a truthy value if the set is a cyclic difference set, or a falsey value otherwise.

Test Cases

Valid cyclic difference sets: 

10,12,17,18,21
7,5,4
57,1,5,7,17,35,38,49
1,24,35,38,40,53,86,108,114,118,135,144,185,210,254,266,273
16,3,19,4,8,10,15,5,6
8,23,11,12,15,2,3,5,7,17,1


(data source, although their convention is different)

Invalid cyclic difference sets:

1,2,3,4,20
57,3,5,7,17,35,38,49
3,4,5,9
14,10,8
Jelly, 14 7 bytes

_þ%ṀṬSE


Try it online!

How it works

_þ%ṀṬSE  Main link. Argument: A (array of unique elements / ordered set)

_þ       Subtract table; yield a 2D array of all possible differences of two
         (not necessarily distinct) elements of A.
  %Ṁ     Take the differences modulo max(A).
    Ṭ    Untruth; map each array of differences modulo max(A) to a Boolean array
         with 1's at the specified indices. Note that all 0's in the index array
         are ignored, since indexing is 1-based in Jelly.
     S   Take the sum of these arrays, counting occurrences.
      E  Test if all resulting counts are equal.