// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
//#define endl '\n'
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 25100, K = 410;

template<typename T, T mod>
struct Tint{
	T val;
	Tint(): val(0){}
	Tint(long long x){ x %= mod; if(x < 0) x += mod; val = x; }
	// basic operations
	Tint& operator += (Tint oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
	Tint& operator -= (Tint oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
	Tint& operator *= (Tint oth){ val = (long long)(val) * oth.val % mod; return *this; }
	Tint operator + (Tint oth) const{ return Tint(*this) += oth; }
	Tint operator - (Tint oth) const{ return Tint(*this) -= oth; }
	Tint operator * (Tint oth) const{ return Tint(*this) *= oth; }
};

// usage
const ll MOD = 1e9+7;
using Mint = Tint<int,MOD>;

int k;

Mint bpow(Mint x, long long p){
	Mint ans;
	for(ans = 1; p; p >>= 1, x = x*x)
		if(p&1) ans = ans * x;
	return ans;
}

bool colorful(vector<int> a){
	set<int> s;
	deque<int> dq;
	for(int x : a){
		if(s.count(x)){
			while(dq.front() != x){ 
				s.erase(dq.front());
				dq.pop_front();
			}
			dq.pop_front();
		}
		s.insert(x);
		dq.push_back(x);
		if(sz(dq) == k) return true;
	}
	return false;
}

int process(vector<int> a){
	set<int> s;
	deque<int> dq;
	for(int x : a){
		if(s.count(x)){
			while(dq.front() != x){
				s.erase(dq.front());
				dq.pop_front();
			}
			dq.pop_front();
		}
		s.insert(x);
		dq.push_back(x);
	}
	return sz(dq);
}

vector<Mint> get(int x){
	vector< vector<Mint> > dp(N,vector<Mint>(k+1));
	dp[0][x] = 1;
	for(int i = 0; i+1 < N; ++i){
		Mint psum;
		for(int j = k-1; j >= 1; --j){
			psum += dp[i][j];
			dp[i+1][j] += psum;
		}
		for(int j = 1; j+1 < k; ++j){
			dp[i+1][j+1] += dp[i][j] * (k-j);
		}
	}
	vector<Mint> ans(N);
	for(int i = 0; i < N; ++i){
		for(int j = 0; j < k; ++j){
			ans[i] += dp[i][j];
		}
	}
	return ans;
}

Mint get2(int m, int n){
	vector< vector< vector<Mint> > > dp(N);
	for(auto &t : dp){
		t.resize(2);
		for(auto &q : t) q.resize(K);
	}
	dp[1][0][1] = k;
	if(m == 1) dp[1][1][1] = k;
	for(int i = 1; i <= n; ++i){
		for(int t = 0; t < 2; ++t){
			for(int c = k-1; c >= 1; --c){
				dp[i][t][c] += dp[i][t][c+1];
				dp[i+1][t][c] = dp[i][t][c];
				dp[i+1][t][c] += dp[i][t][c-1] * (k-c+1);
			}
		}
		for(int c = m; c < k; ++c){
			dp[i+1][1][c] += dp[i+1][0][c];
		}
	}
	return dp[n][1][1];
}

Mint fact[N], ifact[N];

void build_fact(){
	fact[0] = ifact[0] = 1;
	for(int i = 1; i < N; ++i){
		fact[i] = fact[i-1] * i;
		ifact[i] = bpow(fact[i],MOD-2);
	}
}

int main(){

	fastio;
	//cout << "ok" << endl;
	build_fact();
	int n,m;
	cin >> n >> k >> m;
	vector<int> a(m);
	REP(i,m) cin >> a[i];
	//cout << "Se lesho como un campeon" << endl;

	Mint ans = Mint(n-m+1) * bpow(k,n-m);
	//cout << "ok" << endl;
	if(colorful(a)){
		cout << ans.val << endl;
		exit(0);
	}
	//cout << "Not colorful" << endl;
	set<int> s;
	for(int x : a) s.insert(x);
	if(sz(a) != sz(s)){
		int x = process(a);
		reverse(a.begin(),a.end());
		int y = process(a);
		Mint res = 0;
		vector<Mint> vx = get(x);
		vector<Mint> vy = get(y);
		for(int i = 0; i <= n-m; ++i){
			res += vx[i] * vy[n-m-i];
		}
		ans -= res;
	}else{
		Mint res = get2(m,n);
		res *= ifact[k];
		res *= fact[k-m];
		ans -= res;
	}

	cout << ans.val << endl;

	return 0;
}


Measured memory_bytes: 86356