You are given a sequence a_1, a_2, ..., a_n consisting of n integers.

You can choose any non-negative integer D (i.e. D ≥ 0), and for each a_i you can:

  * add D (only once), i. e. perform a_i := a_i + D, or 
  * subtract D (only once), i. e. perform a_i := a_i - D, or 
  * leave the value of a_i unchanged. 



It is possible that after an operation the value a_i becomes negative.

Your goal is to choose such minimum non-negative integer D and perform changes in such a way, that all a_i are equal (i.e. a_1=a_2=...=a_n).

Print the required D or, if it is impossible to choose such value D, print -1.

For example, for array [2, 8] the value D=3 is minimum possible because you can obtain the array [5, 5] if you will add D to 2 and subtract D from 8. And for array [1, 4, 7, 7] the value D=3 is also minimum possible. You can add it to 1 and subtract it from 7 and obtain the array [4, 4, 4, 4].

Input

The first line of the input contains one integer n (1 ≤ n ≤ 100) — the number of elements in a.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100) — the sequence a.

Output

Print one integer — the minimum non-negative integer value D such that if you add this value to some a_i, subtract this value from some a_i and leave some a_i without changes, all obtained values become equal.

If it is impossible to choose such value D, print -1.

Examples

Input


6
1 4 4 7 4 1


Output


3


Input


5
2 2 5 2 5


Output


3


Input


4
1 3 3 7


Output


-1


Input


2
2 8


Output


3
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {

        int n = in.nextInt();
        int [] ar = new int[n];
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            set.add(in.nextInt());
        }

        int [] a = new int[set.size()];
        int [] b = new int[a.length];

        int diff = solve(set,a);

        if(checkUnique(a)) System.out.println(0);
        else {
            for (int i = 0; i < a.length; i++) {
                b[i] = a[i];
            }

            int middle = a[a.length / 2];
            int min = Integer.MAX_VALUE;
            for (int i = diff; i >= 0; i--) {
                for (int j = 0; j < a.length; j++) {
                    if (a[j] < middle) {
                        a[j] += i;
                    } else if (a[j] > middle) {
                        a[j] -= i;
                    }
                }
                if (checkUnique(a)) {
                    min = Math.min(min, i);
                }
                a = b.clone();
            }

            if (min == Integer.MAX_VALUE) {
                System.out.println(-1);
            } else {
                if (a.length % 2 == 0 && min % 2 == 0) {
                    System.out.println(min / 2);
                } else {
                    System.out.println(min);
                }
            }
        }






    }
    private static boolean checkUnique(int [] a) {
        for (int i = 0; i < a.length - 1; i++) {
            if(a[i]!=a[i+1]) return false;
        }
        return true;
    }
    private static int solve(TreeSet<Integer> set,int [] a) {
        int index = 0;
        int prevDiff = -1;
        int prev = -1;
        Iterator<Integer> it = set.iterator();
        while (it.hasNext()) {
            Integer current = it.next();
            a[index++] = current;
            if(prev!=-1) {
                int diff = current - prev;
                if(prevDiff != -1) {
                    if(diff != prevDiff) return -1;
                }
                else prevDiff = diff;
            }
            prev = current;
        }

        return prevDiff;
    }
    private static String reverseTheString(String s) {
        char [] c = s.toCharArray();
        int i = 0;
        int j = c.length - 1;
        while (i<j) {
            char temp = c[i];
            c[i] = c[j];
            c[j] = temp;
            i++;
            j--;
        }
        return new String(c);
    }
    private static int[] prefixSum(int [] a) {
        int [] prefix = new int[a.length+1];
        for (int i = 0; i < a.length; i++) {
            prefix[i+1] = prefix[i] + a[i];
        }
        return prefix;
    }
    private static int solve(int d, String s)  {
        char [] c = s.toCharArray();
        int dam = damage(c);
        int count = 0;
        while(dam > d) {
            swap(c);
            dam = damage(c);
            count++;
        }
        return count;
    }
    private static void swap(char [] c) {
        for(int i=c.length - 1;i>=1;i--) {
            if(c[i]=='S' && c[i-1]=='C') {
                char temp = c[i];
                c[i] = c[i-1];
                c[i-1] = temp;
                break;
            }
        }
    }
    private static boolean checkForImpossible(int d,String  s) {
        char [] c = s.toCharArray();
        Arrays.sort(c);
        int sum = 0;
        for (int i = c.length - 1;i>=0;i--) {
            if(c[i] == 'C') break;
            sum++;
        }
        return sum > d;

    }
    private static int damage(char [] c) {
        int p = 1;
        int s = 0;

        for(int i=0;i<c.length;i++) {
            if(c[i] == 'C') {
                p*=2;
            }
            if(c[i] == 'S') {
                s+=p;
            }
        }
        return s;
    }
    private static int numberOfNineTeens(int [] mainFreq, int [] nineteenFreq) {
        int count = Integer.MAX_VALUE;
        for (int i = 0; i < mainFreq.length; i++) {
            if(nineteenFreq[i]>0) {
                if(mainFreq[i] < nineteenFreq[i]) return 0;
                else {
                    System.out.println((char)(i+'a') + " " + mainFreq[i] + " " + nineteenFreq[i]);
                    int temp = mainFreq[i]/nineteenFreq[i];
                    if(i+'a' == 'n') temp+=1;
                    count = Math.min(count,temp);
                }
            }
        }
        return count;
    }
    private static int [] frequency(String s) {
        int [] freq = new int[26];
        for(char c : s.toCharArray()) {
            freq[c-'a']++;
        }
        return freq;
    }

    static int [] readAnArray(int n) {
        int [] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        return a;
    }
}
