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 Solution implements Runnable{
    FastScanner sc;
    PrintWriter pw;
    final class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
 
        public long nlo() {
            return Long.parseLong(next());
        }
 
        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }
 
        public int ni() {
            return Integer.parseInt(next());
        }
 
        public String nli() {
            String line = "";
            if (st.hasMoreTokens()) line = st.nextToken();
            else try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            while (st.hasMoreTokens()) line += " " + st.nextToken();
            return line;
        }
 
        public double nd() {
            return Double.parseDouble(next());
        }
    }
    public static void main(String[] args) throws Exception
    {
        new Thread(null,new Solution(),"codeforces",1<<28).start();
    }
    public void run()
    {
        sc=new FastScanner();
        pw=new PrintWriter(System.out);
        solve();
        pw.flush();
        pw.close();
    }
    public long gcd(long a,long b)
    {
        return b==0L?a:gcd(b,a%b);
    }
    public long ppow(long a,long b,long mod)
    {
        if(b==0L)
        return 1L;
        long tmp=1;
        while(b>1L)
        {
            if((b&1L)==1)
            tmp*=a;
            a*=a;
            a%=mod;
            tmp%=mod;
            b>>=1;
        }
        return (tmp*a)%mod;
    }
    public  int gcd(int x,int y)
    {
        return y==0?x:gcd(y,x%y);
    }
    //////////////////////////////////
    /////////////  LOGIC  ///////////
    ////////////////////////////////

    public void solve() 
    {
        int n=sc.ni();
        long x=sc.ni();
        long[] prr=new long[64];
        for(int i=0;i<64;i++)
        prr[i]=ppow(x,i,Long.MAX_VALUE);
        long sum=0;
        long[] arr=new long[n];
        for(int i=0;i<n;i++)
        {
            arr[i]=sc.ni();
            sum+=arr[i];
        }
        TreeMap<Long,Long> map=new TreeMap();
        for(int i=n-1;i>=0;i--)
        {
            long k=sum-arr[i];
            if(!map.containsKey(k))
            map.put(k,0L);
            map.put(k,map.get(k)+1L);
        }
        while(map.size()>0)
        {
            long s=map.firstKey();
            long k=map.get(s);
            long p=(long)(Math.log(k)/Math.log(x));
            if(k%x!=0)
            {
                pw.println(ppow(x,Math.min(s,sum),1000000007));
                return;
            }
            for(int l=(int)p;l>0;l--)
            {
                long j=0;
                while(k>=prr[l])
                {
                    j++;
                    k-=prr[l];
                }
                if(j>0)
                {
                    long tmp=s+l;
                    if(!map.containsKey(tmp))
                    map.put(tmp,0L);
                    map.put(tmp,map.get(tmp)+j);
                }
            }
            map.remove(s);
            
        }
        
    }
}