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 static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import static java.lang.Comparable.*;
import java.util.*;
import java.io.*;

import com.sun.org.apache.bcel.internal.generic.NEW;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	final int maxn = 100 * 1000 + 100;
	final long mod = 1000 * 1000 * 1000 + 7;

	int n;
	long x;
	long a[] = new long[maxn];
	// Pair pairs[] = new Pair[maxn];
	// int countP;
	// TreeSet<Pair> pairs = new TreeSet<Main.Pair>();
	TreeMap<Long, Long> powToC = new TreeMap<Long, Long>();

	long binPow(long a, long n) {
		if (n == 0)
			return 1;
		if (n % 2 == 1)
			return (a * binPow(a, n - 1)) % mod;
		else {
			long temp = binPow(a, n / 2);
			return (temp * temp) % mod;
		}
	}

	private void run() throws IOException {
//		in = new BufferedReader(new FileReader("input.txt"));
//		out = new PrintWriter("output.txt");
		 in = new BufferedReader(new InputStreamReader(System.in));
		 out = new PrintWriter(System.out);

		n = nextInt();
		x = nextLong();
		long degree = 0;
		for (int i = 0; i < n; i++)
			degree += (a[i] = nextInt());
		for (int i = 0; i < n; i++) {
			long pow = degree - a[i];
			if (powToC.containsKey(pow))
				powToC.put(pow, powToC.get(pow) + 1);
			else
				powToC.put(pow, (long) 1);
		}
		long ans = 0;
		while (powToC.get(powToC.firstKey()) % x == 0) {
			long pow = powToC.firstKey();
			long k = powToC.remove(pow);
			while (k % x == 0) {
				pow++;
				k /= x;
			}
			if (powToC.containsKey(pow))
				powToC.put(pow, powToC.get(pow) + k);
			else
				powToC.put(pow, k);
		}
		long pow = min(degree, powToC.firstKey());
		ans = binPow(x, pow);

		out.println(ans);

		in.close();
		out.close();
	}

	class Pair implements Comparable<Pair> {
		long k;
		long a;

		Pair(long k, long a) {
			this.k = k;
			this.a = a;
		}

		public int compareTo(Pair pair) {
			if (a != pair.a)
				return Long.valueOf(k).compareTo(pair.k);
			return Long.valueOf(a).compareTo(pair.a);
		}
	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}

	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}
