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.util.*;
import java.io.*;
import java.math.*;

public class Main {
    static BufferedReader reader 
		= new BufferedReader(new InputStreamReader(System.in));       
    static StringBuilder out = new StringBuilder();

    public static void main(String[] args){
        long[] inp = nextLongArray();
        long n, x;
        n = inp[0]; x = inp[1];
        long[] a = nextLongArray();
        BigInteger s = BigInteger.valueOf(0);
        for (long i : a) s = s.add(BigInteger.valueOf(i));
        TreeMap<BigInteger, Long> coefficient = new TreeMap<BigInteger, Long>(); 
        // coefficient.get(i) is the coefficiet of x ^ i
        for (long i : a){
            BigInteger key = s.subtract(BigInteger.valueOf(i));
            if (coefficient.containsKey(key)){
                coefficient.put(key, coefficient.get(key) + 1);
            } else {
                coefficient.put(key, (long) 1);
            }
        }
        BigInteger key = coefficient.firstKey();

        while (true){
            long c = coefficient.get(key);
            if (c < x){
                break;
            } else {
                int cnt = 0;
                while (c % x == 0){
                    c /= x;
                    cnt ++;
                }
                if (cnt == 0){
                    break;
                }
                BigInteger newKey = key.add(BigInteger.valueOf(cnt));
                if (coefficient.containsKey(newKey)){
                    coefficient.put(newKey, coefficient.get(newKey) + c);
                } else {
                    coefficient.put(newKey, Long.valueOf(c % x));
                }
                key = coefficient.ceilingKey(key.add(BigInteger.valueOf(1)));
                // System.out.println(key);
            }
        }
        // System.out.println(x + " " + key);
        if (key.compareTo(s) == 1){
            key = s;
        }
        long ans = BigInteger.valueOf(x).modPow(key, BigInteger.valueOf((long) 1e9 + 7)).longValue();
        out.append(ans);

        System.out.println(out);
    }
    static long myLog(long a, long b){
        if (b == 1){
            return -1;
        }
        long cnt = 0;
        long acc = 1;
        while (acc < b){
            acc *= a;
            cnt ++;
        }
        return cnt == b ? cnt : -1;
    }
    static boolean isInteger(double d){
        return Math.abs(d - Math.floor(0.5 + d)) < 0.000001;
    }

    // the followings are methods to take care of inputs.
    static int nextInt(){
        return Integer.parseInt(nextLine());
    }
    static long nextLong(){
        return Long.parseLong(nextLine());
    }
    static int[] nextIntArray(){
        String[] inp = nextLine().split("\\s+");
        int[] ary = new int[inp.length]; for (int i = 0; i < ary.length; i++){
            ary[i] = Integer.parseInt(inp[i]);
        }
        return ary;
    }
    static int[] nextIntArrayFrom1(){
        String[] inp = nextLine().split("\\s+");
        int[] ary = new int[inp.length + 1];
        for (int i = 0; i < inp.length; i++){
            ary[i+1] = Integer.parseInt(inp[i]);
        }
        return ary;
    }
    static long[] nextLongArray(){
        String[] inp = nextLine().split("\\s+");
        long[] ary = new long[inp.length];
        for (int i = 0; i < inp.length; i++){
            ary[i] = Long.parseLong(inp[i]);
        }
        return ary;
    }
    static long[] nextLongArrayFrom1(){
        String[] inp = nextLine().split("\\s+");
        long[] ary = new long[inp.length + 1];
        for (int i = 0; i < inp.length; i++){
            ary[i+1] = Long.parseLong(inp[i]);
        }
        return ary;
    }
	static String nextLine(){
		try { 
			return reader.readLine().trim();
		} catch (Exception e){}
		return null;
	}
}

