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

public class Main {

    public static void main(String[] args) throws IOException {
        try {
            if (new File("input.txt").exists())
                System.setIn(new FileInputStream("input.txt"));
        } catch (SecurityException e) {
        }
        new Main().run();
    }

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

    private void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }
    
    final long MOD = 1000 * 1000 * 1000 + 7;
    class Pair implements Comparable<Pair>{
        long first,second;      
        public Pair(long f, long s){
            first = f;
            second = s;
        }
        public int compareTo(Pair o) {
            return Long.valueOf(first).compareTo(o.first);
        }       
    }
    long binpow(long a, long n){
        if(n == 0)
            return 1L;
        long b  = binpow(a,n/2) % MOD;
        b = (b*b) % MOD;
        if(n % 2 == 1)
            b = (b*a)%MOD;
        return b;
    }
    
    public void solve() throws IOException{
        int n = nextInt();
        long x = nextLong();
        int[] a = new int[n];
        long t = 0;
        for(int i = 0; i < n; i++){
            a[i] = nextInt();
            t += (long)a[i];
        }
        TreeSet<Pair> set = new TreeSet<Pair>();
        TreeMap<Long, Long> map = new TreeMap<Long, Long>();
        for(int i = 0; i < n; i++){
            long shift = t - (long)a[i];
            Pair p = new Pair(shift,1L);
            if(!set.contains(p)){
                set.add(p);
            } else {
                Pair q = set.ceiling(p);
                q.second++;
            }
//          if(map.containsKey(shift))
//              map.put(shift,map.get(shift)+1L);
//          else
//              map.put(shift,1L);
        }
        while(set.first().second % x == 0){
//      while(map.get(map.firstKey()) % x == 0){
//          long shift = map.firstKey();
//          long deg = map.remove(shift);
//          map.put(shift+1,deg/x);
            Pair p = set.first();
            Pair q = new Pair(p.first + 1,p.second/x);
            set.remove(p);
            if(!set.contains(q))
                set.add(q);
            else 
                set.first().second += q.second;
        }
        long answer = binpow(x,min(t,set.first().first));
        out.println(answer);
    }

    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;
    }
}
