Find the size of distinct elements array if we pick any two elements and insert their absolute difference along with the two elements.

Input: size and elements

6

9 6 12 15 24 27

Output:

9

I tried to find gcd of elements and divide it with max element in the array ,but it is failing for some test cases. Please suggest the approach with optimum complexity