#include<bits/stdc++.h>
using namespace std;
#define int long long
const int M=1e9+7,N=50005,K=405;
int n,k,m,a[N],cnt[N],sum[N],sum2[N],dp1[N],inv[N],dp2[N],fac[N],f[N][K],g[N][K],p[N];
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
signed main(){
	fac[0]=1;
//	for (int i=1;i<=n;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	scanf("%lld%lld%lld",&n,&k,&m);
	for (int i=1;i<=n;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);	
	for (int i=1;i<=m;i++)scanf("%lld",&a[i]);
	int num=0;
	for (int i=1;i<=m;i++){
		num+=!cnt[a[i]];
		cnt[a[i]]++;
		if (i>k){
			num-=cnt[a[i-k]]==1;
			cnt[a[i-k]]--;
		}
		if (num==k){
			int ans=n-m+1;
			for (int i=1;i<=n-m;i++)(ans*=k)%=M;
			printf("%lld\n",ans);
			return 0;
		}
	}
	memset(cnt,0,sizeof cnt);
	int k1=m,k2=m;
	for (int i=1;i<=m;i++){
		if (cnt[a[i]]){
			k1=i-1;
			break;
		}
		cnt[a[i]]=1;
	}
	memset(cnt,0,sizeof cnt);
	for (int i=m;i;i--){
		if (cnt[a[i]]){
			k2=m-i;
			break;
		}
		cnt[a[i]]=1;
	}
	p[0]=1;
	for (int i=1;i<=n;i++)p[i]=p[i-1]*k%M;	
	if (k1==m){
		if (n<k){
			puts("0");
			return 0;
		}
        f[0][0]=1;
        int tmp=0,ans=(n-m+1)*p[n-m]%M;
        for (int i=1;i<=n;i++){
            for (int j=1;j<k;j++){
                (f[i][j]+=f[i-1][j-1]*(k-j+1)%M)%=M;
                (f[i][j]+=sum[k]+M-sum[j-1])%=M;
                (g[i][j]+=g[i-1][j-1]*(k-j+1))%=M;
                (g[i][j]+=sum2[k]+M-sum2[j-1])%=M;
                if (j>=m)(g[i][j]+=f[i][j])%=M;
            }
            for (int j=1;j<=k;j++){
                sum[j]=(sum[j-1]+f[i][j])%M;
                sum2[j]=(sum2[j-1]+g[i][j])%M;
            }
        }
        for (int j=0;j<k;j++)(tmp+=g[n][j])%=M;
        (tmp*=ksm(fac[k]*inv[k-m]%M,M-2))%=M;
        printf("%lld\n",(ans-tmp+M)%M);
		return 0;
	}
	f[0][k1]=1;
	for (int i=1;i<=k1;i++)g[0][i]=1;
	for (int i=1;i<=n;i++){
		for (int j=k-1;j;j--){
			f[i][j]=(g[i-1][j]+f[i-1][j-1]*(k-j+1))%M;
			g[i][j]=(g[i][j+1]+f[i][j])%M;
		}
		dp1[i]=(dp1[i-1]*k+f[i-1][k-1])%M;
	}
	memset(f,0,sizeof f);
	memset(g,0,sizeof g);
	f[0][k2]=1;
	for (int i=1;i<=k2;i++)g[0][i]=1;
	for (int i=1;i<=n;i++){
		for (int j=k-1;j;j--){
			f[i][j]=(g[i-1][j]+f[i-1][j-1]*(k-j+1))%M;
			g[i][j]=(g[i][j+1]+f[i][j])%M;
		}
		dp2[i]=(dp2[i-1]*k+f[i-1][k-1])%M;
	}
	int ans=0;
	for (int i=0;i<=n-m;i++)
		(ans+=dp1[i]*p[n-m-i]+dp2[n-m-i]*p[i]-dp1[i]*dp2[n-m-i])%=M;
	printf("%lld\n",(ans+M)%M);	
}