For this Question: <i>We all remember phone numbers, account numbers, etc. by creating a pattern in our brains, but forget them entirely if we fail to recall the initial numbers or characters. </i>

Saloni is highly engrossed with studying the number patterns in the Vedic math. She knows there exists a golden sequence of numbers which can entirely change the understanding of the technology. Since she has memorised the golden sequence once when she was 5, <b>she will identify the golden sequence as soon as it appears in front of her as the prefix of any sequence</b>.

So, to recall the golden sequence, she first creates an empty sequence S and chooses a number X. Now, in each move she appends an integer randomly selected from the integers between 1 to X, at the front of the sequence S. As soon as the golden sequence appears as the prefix of the sequence S, she recalls the golden sequence. 

Now given the golden sequence G, find the expected length of the sequence S when Saloni recalls the golden sequence.The first line of the input contains two integer N and X, the length of the golden sequence and the integer chosen by Saloni.
The second line of the input contains N space separated integers denoting the golden sequence G.

Constraints
1 <= N <= 200000
1 <= G[i] <= 1000000
1 <= X <= 1000000
If she can never recall the golden sequence under the given constraints, output -1. Else, if the answer is of the form p/q, output it as (p*r)%1000000007 where r is modulo inverse of q with respect to 1000000007.Sample Input
1 11
7

Sample Output
11

Explanation: Saloni keeps on generating a random integer between 1 to 11 until she gets the number 7. Using simple concepts of geometric distribution, we know the expected length of sequence will be 11.  


Sample Input
4 12
7 9 7 9 

Sample Output
20880

Sample Input
3 14
12 15 17

Sample Output
-1
, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int Z[N];

int powmod(int a, int b){
    int ans = 1;
    while(b){
        if(b&1)
            ans = (ans*a) % MOD;
        b >>= 1;
        a = (a*a) % MOD;
    }
    return ans;
}

void getZarr(vector<int>& vect){
    int n = vect.size();
    int L, R, k;
    L = R = 0;
    for (int i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && vect[R-L] == vect[R])
                R++;
            Z[i] = R-L;
            R--;
        }
        else{
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else{
                L = i;
                while (R<n && vect[R-L] == vect[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}

void solve(){
    int n, x; cin>>n>>x;
    vector<int> vect(n);
    bool fl = true;
    For(i, 0, n){
        cin>>vect[i];
        if(vect[i] > x){
            fl = false;
        }
    }
    if(!fl){
        cout<<-1;
        return;
    }
    reverse(all(vect));
    getZarr(vect);
    int ans = powmod(x, n);
    for(int i = 1; i < n; i++){
        if(Z[i]+i == n)
            ans = (ans + powmod(x, Z[i])) % MOD;
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}

, In this Programming Language: C++, Now tell me if this Code is compilable or not?