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


public class solver {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    
    final boolean OJ=System.getProperty("ONLINE_JUDGE")!=null;
    
    String readString() throws IOException{
        while (tok==null || !tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine()); 
        }
        return tok.nextToken();
    }
    int readInt() throws NumberFormatException, IOException{
        return Integer.parseInt(readString());
    }
    long readLong() throws NumberFormatException, IOException{
        return Long.parseLong(readString());
    }
    double readDouble() throws NumberFormatException, IOException{
        return Double.parseDouble(readString());
    }
    
    int gcd(int a,int b){
        return (b==0)?a:gcd(b,a%b);     
    }
    
    long pow(int x,long n){
        if (n==0)return 1;
        if (n%2==1) {
            return x*pow(x,n-1)%mod;
        }
        long b=pow(x,n/2);
        return (b*b)%mod;       
    }
    
    
   
    
   
    
    final int mod=(int)1e9+7;
    void Solve() throws NumberFormatException, IOException{
        int n=readInt();
        int x=readInt();
        int[] a=new int[n];
        long sum=0;
        for (int i=0;i<n;i++){
            a[i]=readInt();
            sum+=a[i];
        }
        long k=Long.MAX_VALUE;
        TreeMap<Long,Integer> map=new TreeMap<Long,Integer>();
        for (int i=0;i<n;i++){
            long y=sum-a[i];             
            k=Math.min(k, y);
            if (y==0) continue;
            if (!map.containsKey(y)){
                map.put(y, 0);
            }
            map.put(y, map.get(y)+1);
        }
        
        int m=0;
        for (Map.Entry<Long, Integer> e:map.entrySet()){
            while (k<e.getKey() && m%x==0){
                k++;
                m/=x;
            }
            if (k==e.getKey()){
                m+=e.getValue();
            }else{
                long ans=pow(x,k)%mod;
                out.println(ans);
                return;
            }           
        }
        while (m!=0 && m%x==0) {
            k++;
            m/=x;
        }
        long ans=pow(x,Math.min(k, sum))%mod;
        out.println(ans);
        
        
        
        
        
      
        
    
        
        
        
            
        
        
        
    }
    void Run() throws NumberFormatException, IOException{
        if (OJ){
            in =new BufferedReader(new InputStreamReader(System.in));
            out=new PrintWriter(System.out);            
        }else{          
            in=new BufferedReader(new FileReader("input.txt"));
            out=new PrintWriter("output.txt");          
        }
        
        long h=System.currentTimeMillis();
        Solve();    
       // System.err.println(System.currentTimeMillis()-h);
        in.close();
        out.close();
    }
    public static void main(String[] args) throws NumberFormatException, IOException{
        new solver().Run();
    }
}