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.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;

public class PrimeNumber 
{
	static BigInteger modbi;
	static BigInteger xbi;
	
	static void doit(long pow)
	{
		long r = xbi.modPow(new BigInteger(Long.toString(pow)), modbi).longValueExact();
		
		System.out.println(r);
	}
	static long MOD = 1000000007;
	
	public static void main(String[] args) 
	{
		FastReader sc = new FastReader();
		
		
		int n = sc.nextInt();
		
		long x = sc.nextLong();
		
		modbi = new BigInteger(Long.toString(MOD));
		xbi = new BigInteger(Long.toString(x));

		long[] a = new long[n];
		long sum = 0;
		boolean debug = false;
//		long minpow = 9000000000l;
		
		for(int i = 0; i < n; i++)
		{
			long in = sc.nextLong();
			a[i] = in;
			sum += in;
//			minpow = Math.min(minpow, a[i]);
			
			// sum - a[i]
		}
		for(int i = 0; i < n; i++)
		{
			a[i] = sum - a[i];
		}
		
		Arrays.sort(a);
		if(debug)System.out.println(Arrays.toString(a));
		
		
		long curm = 0; //current power's multiplier
		long prevpow = -1;
		for(int i = 0; i < n; i++)
		{ //iterate from the smallest
//			if(a[i] != 0)
			{
				if(debug)System.out.println("POW " + a[i] + ", prev: " + prevpow);
				if(prevpow == a[i])
				{
					//same power as before
				}
				else
				{
					//new power
					if(prevpow > -1)
					{
						//attempt to convert previous power multiplier to this power's multiplier.
						if(curm%x == 0)
						{ 
							if(debug)System.out.println("Attempt to raise");
							int raise = 0;
							long diff = a[i] - a[i-1];
							while(raise < diff && curm%x == 0)
							{
								curm = curm/x; //later use big integer?
								raise++;
							}
							
							if(raise < diff)
							{
								//the max raise becomes the min.
								long pow1 = a[i-1] + raise;
								if(debug)System.out.println("POWPOW " + pow1 + ", " + a[i-1] + " " + raise);
								long pow = Math.min(sum, pow1);
								doit(pow);
								return;
							}
							else
							{
								if(debug)System.out.println("RAISE");
							}
						}
						else
						{ //no longer divisible by x --> over. previous one was min.
							if(debug)System.out.println("End on " + a[i]);
							long pow = Math.min(sum, a[i-1]);

//							long r = (long) Math.pow(x, Math.min(sum, a[i-1]));
//							System.out.println(r);
							
							doit(pow);
							return;
//							curm = 0;
						}
					}
				}
				
				curm++;
				prevpow = a[i];
			}
		}
		
		//lastly, attempt to convert the final power multiplier to the highest power possible
		//using the remainder multiplier.
		long lastmult = a[n-1];
		if(curm%x == 0)
		{ 
			while(curm%x == 0 && lastmult > 0)
			{
				curm = curm/x; //later use big integer?
				lastmult++;
				if(debug)System.out.println("Raise " + lastmult);
			}
		}		
		
		long pow =  Math.min(sum, lastmult);
		doit(pow);
		return;
		
		
	}
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreElements()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	    } 
}
