func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5, mod = 1e9 + 7;   long long a[N], x, n, sum;   long long fastpower(long long b, long long p) {     if (p == 0) return 1;     long long halfpower = fastpower(b, p / 2) % mod;     halfpower *= halfpower;     halfpower %= mod;     if (p % 2) halfpower = (halfpower * (b % mod)) % mod;     return halfpower;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> x;     for (int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     map<long long, long long> mp;     for (int i = 0; i < n; i++) mp[sum - a[i]]++;     for (auto i : mp) {       mp[i.first + 1] += (i.second / x);       if (i.second % x) {         cout << fastpower(x, min(i.first, sum));         return 0;       }     }   }   