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.
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
const int MOD = 1000000007;
const int INF = 1e8;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-7;
long long fexp(long long b, long long e) {
  if (e == 0) return 1;
  long long res = fexp(b, e / 2);
  res = (res * res) % MOD;
  if (e % 2) res = (b * res) % MOD;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, x;
  cin >> n >> x;
  long long soma = 0;
  vector<long long> v(n), v2;
  for (int i = 0; i < (int)n; i++) {
    cin >> v[i];
    soma += v[i];
  }
  for (int i = 0; i < (int)n; i++) {
    v[i] = soma - v[i];
  }
  sort(v.begin(), v.end());
  stack<long long> pil;
  map<long long, long long> make_pair;
  for (int i = 0; i < (int)n; i++) pil.push(v[i]);
  while (!pil.empty()) {
    long long val = pil.top();
    pil.pop();
    make_pair[val]++;
    if (make_pair[val] == x) {
      make_pair[val] = 0;
      pil.push(val + 1);
    }
  }
  for (auto p : make_pair) {
    if (p.second != 0) {
      v2.push_back(p.first);
    }
  }
  swap(v, v2);
  sort(v.begin(), v.end());
  long long res = min(soma, v[0]);
  cout << fexp(x, res) << '\n';
  return 0;
}
