func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long maxn = 100005;   const long long p = 1e9 + 7;   long long a[maxn], n, x, sum;   long long st[maxn], top;   vector<long long> v;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline long long qpow(long long x, long long y) {     long long res = 1;     while (y) {       if (y & 1) res = (res * x % p) % p;       x = (x % p * x % p) % p;       y >>= 1;     }     return res % p;   }   signed main() {     n = read();     x = read();     for (long long i = 1; i <= n; i++) a[i] = read(), sum += a[i];     for (long long i = 1; i <= n; i++) st[++top] = sum - a[i];     sort(st + 1, st + n + 1);     reverse(st + 1, st + n + 1);     while (1) {       long long res = st[top], cnt = 0;       while (top > 0 && res == st[top]) cnt++, top--;       if (cnt % x) {         printf( %d , qpow(x, min(sum, res)));         return 0;       } else {         cnt /= x;         for (long long i = 1; i <= cnt; i++) st[++top] = res + 1;       }     }     return 0;   }   