#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll N,K,M;
ll A[250010];
ll cnt[401];
ll fac[250001],finv[250001];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  fac[0]=1;
  rep(i,250000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,250001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>N>>K>>M;
  rep(i,M){
    cin>>A[i];
    A[i]--;
  }

  ll tot=mod_pow(K,N-M)*(N-M+1)%mod;

  ll num=0;
  set<ll> st;
  rep(i,M){
    st.insert(A[i]);
    if(i>=K){
      if(cnt[A[i-K]]==1)num--;
      cnt[A[i-K]]--;
    }
    if(cnt[A[i]]==0)num++;
    cnt[A[i]]++;

    if(num==K){ // colorful
      cout<<tot<<endl;
      return 0;
    }
  }

  if((ll)st.size()==M){ // distinct
    vector<vector<vector<ll> > > dp(2,vector<vector<ll> >(K-1,vector<ll>(2,0)));
    ll crt=0,nxt=1;
    dp[crt][0][0]=K;
    if(M==1){
      dp[crt][0][1]=K;
    }
    rep(i,N-1){
      rep(j,K-1)rep(k,2)dp[nxt][j][k]=0;
      vector<vector<ll> > sum(K-1,vector<ll>(2,0));
      for(ll j=K-2;j>=0;j--)rep(k,2){
        (sum[j][k]+=dp[crt][j][k])%=mod;
        if(j<K-2)(sum[j][k]+=sum[j+1][k])%=mod;
      }
      rep(j,K-1)rep(k,2){
        if(j==0){
          (dp[nxt][j][k]+=sum[j][k])%=mod;
          if(k==0&&j+1>=M){
            (dp[nxt][j][1]+=sum[j][k])%=mod;
          }
        }else{
          (dp[nxt][j][k]+=sum[j][k]+(dp[crt][j-1][k]*(K-j)%mod))%=mod;
          if(k==0&&j+1>=M){
            (dp[nxt][j][1]+=sum[j][k]+(dp[crt][j-1][k]*(K-j)%mod))%=mod;
          }
        }
      }
      swap(crt,nxt);
    }
    ll res=0;
    rep(j,K-1)(res+=dp[crt][j][1])%=mod;
    ll f=finv[K]*fac[K-M]%mod;
    cout<<(tot-(res*f%mod)+mod)%mod<<endl;
  }else{ // not distinct

    ll prf=0,suf=0;
    rep(i,K)cnt[i]=0;
    while(1){
      if(cnt[A[prf]])break;
      cnt[A[prf]]++; prf++;
    }
    rep(i,K)cnt[i]=0;
    while(1){
      if(cnt[A[M-1-suf]])break;
      cnt[A[M-1-suf]]++; suf++;
    }

    vector<vector<ll> > dp(N+1,vector<ll>(K-1,0));

    dp[1][0]=K;
    repl(i,1,N){
      vector<ll> sum(K-1,0);
      for(ll j=K-2;j>=0;j--){
        (sum[j]+=dp[i][j])%=mod;
        if(j<K-2)(sum[j]+=sum[j+1])%=mod;
      }
      rep(j,K-1){
        if(j==0){
          (dp[i+1][j]+=sum[j])%=mod;
        }else{
          (dp[i+1][j]+=sum[j]+(dp[i][j-1]*(K-j)%mod))%=mod;
        }
      }
    }

    ll res=0;
    ll s=mod_pow(K,N-M);
    rep(i,N-M+1){
      ll prflen=i+prf;
      ll f1=finv[K]*fac[K-prf]%mod;
      ll prfnum=0;
      repl(j,prf-1,K-1)prfnum+=dp[prflen][j]*f1%mod;
      prfnum%=mod;

      ll suflen=N-i-M+suf;
      ll f2=finv[K]*fac[K-suf]%mod;
      ll sufnum=0;
      repl(j,suf-1,K-1)sufnum+=dp[suflen][j]*f2%mod;
      sufnum%=mod;

      (res+=(s-(prfnum*sufnum%mod)+mod))%=mod;
    }
    cout<<res<<endl;
  }

  return 0;
}


Measured memory_bytes: 83072