#include<cstring>
#include<iostream>
#define DIM 25005
#define mod 1000000007
using namespace std;
int n, k, m, i, j, sum, p, ok, ok2, sol, x, y;
int d[DIM][405], sd[DIM][405], s[DIM], v[DIM], ff[405], fact[405], ar[405][405], d2[DIM][405], s2[DIM], sd2[DIM][405];
//ifstream cin("date.in");
//ofstream cout("date.out");
int modul(int x){
    if(x >= mod){
        return x - mod;
    }
    if(x < 0){
        return x + mod;
    }
    return x;
}
void invmod2(long long a, long long b, long long &x, long long &y){
    if(b == 0){
        x = 1;
        y = 0;
    }
    else{
        long long x2, y2;
        invmod2(b, a % b, x2, y2);
        x = y2;
        y = x2 - a / b * y2;
    }
}
int invmod(int a){
    long long x, y;
    invmod2(a, mod, x, y);
    x %= mod;
    return modul(x);
}
int main(){
    cin>> n >> k >> m;
    for(i = 1; i <= m; i++){
        cin>> v[i];
    }
    sum = n - m + 1;
    for(i = 1; i <= n - m; i++){
        sum = sum * 1LL * k % mod;
    }
    d[1][1] = sd[1][1] = s[1] = k;
    for(i = 2; i <= n; i++){
        for(j = 1; j <= min(i, k - 1); j++){
            d[i][j] = d[i - 1][j - 1] * 1LL * (k - j + 1) % mod;
            d[i][j] = modul(d[i][j] + s[i - 1] - sd[i - 1][j - 1]);
            s[i] = modul(s[i] + d[i][j]);
            sd[i][j] = modul(sd[i][j - 1] + d[i][j]);
        }
    }
    p = 1;
    for(i = 1; i <= m; i++){
        p = max(p, ff[ v[i] ] + 1);
        if(ff[ v[i] ] != 0){
            ok2 = 1;
        }
        ff[ v[i] ] = i;
        if(i - p + 1 == k){
            ok = 1;
        }
    }
    if(ok == 1){
        cout<< sum;
        return 0;
    }
    fact[0] = 1;
    for(i = 1; i <= k; i++){
        fact[i] = fact[i - 1] * 1LL * i % mod;
    }
    ar[0][0] = 1;
    for(i = 1; i <= k; i++){
        ar[i][0] = 1;
        for(j = 1; j <= i; j++){
            ar[i][j] = modul(ar[i - 1][j] + ar[i - 1][j - 1]);
        }
    }
    for(i = 1; i <= k; i++){
        for(j = 1; j <= k; j++){
            ar[i][j] = ar[i][j] * 1LL * fact[j] % mod;
        }
    }
    if(ok2 == 0){
        for(i = m; i <= n; i++){
            for(j = 1; j <= min(i, k - 1); j++){
                d2[i][j] = d2[i - 1][j - 1] * 1LL * (k - j + 1) % mod;
                d2[i][j] = modul(d2[i][j] + s2[i - 1] - sd2[i - 1][j - 1]);
                if(j >= m){
                    d2[i][j] = modul(d2[i][j] + d[i][j]);
                }
                s2[i] = modul(s2[i] + d2[i][j]);
                sd2[i][j] = modul(sd2[i][j - 1] + d2[i][j]);
            }
        }
        sol = s2[n] * 1LL * invmod(ar[k][m]) % mod;
    }
    else{
        memset(ff, 0, sizeof(ff));
        for(i = 1; i <= m; i++){
            if(ff[ v[i] ] == 1){
                x = i - 1;
                break;
            }
            else{
                ff[ v[i] ] = 1;
            }
        }
        memset(ff, 0, sizeof(ff));
        for(i = m; i >= 1; i--){
            if(ff[ v[i] ] == 1){
                y = m - i;
                break;
            }
            else{
                ff[ v[i] ] = 1;
            }
        }
        for(i = 0; i <= n - m; i++){
            sol = ( sol + modul(s[i + x] - sd[i + x][x - 1]) * 1LL * modul(s[n - m - i + y] - sd[n - m - i + y][y - 1]) ) % mod;
        }
        sol = sol * 1LL * invmod(ar[k][x]) % mod * invmod(ar[k][y]) % mod;
    }
    sol = modul(sum - sol);
    cout<< sol;
    return 0;
}


Measured memory_bytes: 159360