#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=25005,M=405,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,K,m,a[N],h[M],fir,las,ans;
int f[N][M],sf[N],g[N][M],sg[N];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
void solve(int f[][M]){
	for (int i=1;i<=n;i++){
		int s=0;
		for (int j=K-1;j;j--){
			check(s,f[i-1][j]);
			f[i][j]=(s+(ll)f[i-1][j-1]*(K-j+1))%p;
		}
	}
}
void solve2(){
	for (int i=1;i<=n;i++){
		int s=0,sg=0;
		for (int j=K-1;j;j--){
			check(s,f[i-1][j]);check(sg,g[i-1][j]);
			f[i][j]=(s+(ll)f[i-1][j-1]*(K-j+1))%p;
			g[i][j]=(sg+(ll)g[i-1][j-1]*(K-j+1))%p;
			if (j>=m) check(g[i][j],f[i][j]);
		}
	}
}
int main(){
	n=read();K=read();m=read();
	int fl=1;
	for (int i=1;i<=m;i++){
		a[i]=read();
		if (h[a[i]]){
			if (!fir) fir=i;
			las=max(las,h[a[i]]);
		}
		if (las+K==i) {fl=0;break;}
		h[a[i]]=i;
	}
	ans=(ll)qpow(K,n-m)*(n-m+1)%p;
	if (fl){
		if (fir){
			f[0][fir-1]=1;
			solve(f);
			for (int i=0;i<=n;i++)
			for (int j=0;j<K;j++)
			check(sf[i],f[i][j]);
			g[0][m-las]=1;
			solve(g);
			for (int i=0;i<=n;i++)
			for (int j=0;j<K;j++)
			check(sg[i],g[i][j]);
			for (int i=0;i<=n-m;i++)
			check(ans,p-(ll)sf[i]*sg[n-m-i]%p);
		}
		else{
			f[0][0]=1;
			solve2();
			int s=0,t=1;
			for (int i=0;i<K;i++) check(s,g[n][i]);
			for (int i=(K-m+1);i<=K;i++) t=(ll)t*i%p;
			check(ans,p-(ll)s*qpow(t,p-2)%p);
		}
	}
	printf("%d\n",ans);
	return 0;
}