Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.

Simon loves fractions very much. Today he wrote out number <image> on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: <image>, where number t equals xa1 + a2 + ... + an. Now Simon wants to reduce the resulting fraction. 

Help him, find the greatest common divisor of numbers s and t. As GCD can be rather large, print it as a remainder after dividing it by number 1000000007 (109 + 7).

Input

The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number.

The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). 

Output

Print a single number — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

2 2
2 2


Output

8


Input

3 3
1 2 3


Output

27


Input

2 2
29 29


Output

73741817


Input

4 5
0 0 0 0


Output

1

Note

In the first sample <image>. Thus, the answer to the problem is 8.

In the second sample, <image>. The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.

In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.

In the fourth sample <image>. Thus, the answer to the problem is 1.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class P_359C {
    static final FS sc = new FS();
    static final PrintWriter pw = new PrintWriter(System.out);
    static final long MOD = (long) (1e9+7);
    static long power(long x, long n){
        if(n==0) return 1;
        else if(n==1) return x%MOD;
        long y = 1;
        while(n>1){
            if((n&1)==0){
                x = x*x;
                x %= MOD;
                n = n/2;
            }
            else{
                y = y*x;
                y %= MOD;
                x = x*x;
                x %= MOD;
                n = (n-1)/2;
            }
        }
        return (x*y)%MOD;
    }
    static long gcd(long a, long b){
        if(b>a){
            long temp = a;
            a = b;
            b = temp;
        }
        if(b==0) return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) {
        int n = sc.nextInt();
        long x = sc.nextLong();
        long[] a = sc.nextLongArray(n);
        long sum = 0;
        long max = 0;
        for(int i=0; i<n; i++){
            if(max<a[i]) max = a[i];
            sum += a[i];
        }
        TreeMap<Long, Integer> map = new TreeMap<>();
        for(int i=0; i<n; i++){
            a[i] = (int) (max-a[i]);
            if(map.containsKey(a[i])){
                int val = map.get(a[i]);
                val++;
                map.put(a[i], val);
            }
            else{
                map.put(a[i],1);
            }
        }
        long i= 0;
        while(map.get(i)%x==0){

            if(map.containsKey(i+1)){
                int val = map.get(i+1);
                int val2 = (int) (map.get(i)/x);
                map.put((i+1), val+val2);
            }
            else{
                int val2 = (int) (map.get(i)/x);
                map.put((i+1), val2);
            }
            i++;
        }
        sum -= max;
        sum += Math.min(i,max);
        System.out.println(power(x,sum));
//        Arrays.sort(ord);


    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception ignored) {
                }
            }
            return st.nextToken();
        }

        int[] nextArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
