#include<bits/stdc++.h>

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 3e4 + 5;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

typedef pair<int,int>   ii;
typedef vector<int>     vi;

int f[N][500];
int s[N][500];

int x[N];
int y[N];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;
    int k;  cin >> k;
    int m;  cin >> m;

    auto Case = [&](vi  a)  {
        vector<int> lst(k,-1);
        vector<int> cnt(k,0);

        int lef = -1;

        for(int i = 0 ; i < m ; ++i)    {
            int x = a[i];
            if (lst[x] >= 0)
                lef = max(lef,lst[x]);

            if (lef == i - k)
                return  0;

            lst[x] = i;
        }
        for(int x : a)  {
            if (cnt[x]) return  2;
            else        cnt[x] = 1;
        }
        return  1;
    };
    auto calc = [&](int st,int *h)  {
        f[0][st] = 1;
        h[0] = 1;

        for(int i = 1 ; i <= n ; ++i)   {
            int S = f[i - 1][k - 1];
            for(int j = k - 1 ; j > 0 ; --j)    {
                f[i][j] = 0;
                add(f[i][j],S);
                add(f[i][j],mul(k - j + 1,f[i - 1][j - 1]));

                add(S,f[i - 1][j - 1]);
                add(h[i],f[i][j]);
            }
        }
        f[0][st] = 0;
    };
    vector<int> a(m);

    for(int&x : a)
        cin >> x,
        x -= 1;

    int type = Case(a);
    int Sum  = mul(Pow(k,n - m),n - m + 1);
    int ans = 0;

    if (type == 0)  return  cout << Sum,0;
    if (type == 1)  {
        calc(0,x);

        for(int i = 1 ; i <= n ; ++i)   {
            for(int j = 1 ; j < k ; ++j)    add(s[i][j + 1],s[i][j]);
            for(int j = m ; j < k ; ++j)    add(s[i][j],f[i][j]);

            for(int j = 1 ; j < k ; ++j)    if (s[i][j])    {
                add(s[i + 1][j + 1],mul(s[i][j],k - j - 1));
                sub(s[i + 1][j + 2],mul(s[i][j],k - j));

                add(s[i + 1][1],s[i][j]);
            }
        }
        for(int i = 1 ; i < k ; ++i)    add(ans,s[n][i]);
        for(int i = 0 ; i < m ; ++i)    ans = mul(ans,inv(k - i,mod));
    }
    if (type == 2)  {
        vector<bool> have(k,0);

        int F = 0;
        int B = 0;

        for(int x : a)  {
            if (have[x])
                break;
            F++;
            have[x] = 1;
        }
        reverse(all(a));
        have.assign(k,0);

        for(int x : a)  {
            if (have[x])
                break;
            B++;
            have[x] = 1;
        }
        calc(F,x);
        calc(B,y);

        for(int i = 0 ; i <= n - m ; ++i)
            add(ans,mul(x[i],y[n - m - i]));
    }

    sub(Sum,ans);

    cout << Sum << endl;
}

Measured memory_bytes: 100480