#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> bool chmin(T& a,const T& b) {
  if(a>b) {
    a=b;
    return true;
  }
  return false;
}
template<class T> bool chmax(T& a,const T& b) {
  if(a<b){
    a=b;
    return true;
  }
  return false;
}

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}
template<lint mod>
struct Int_{
  unsigned x;
  unsigned mpow(Int_ a,unsigned k){
    Int_ res=1;
    while(k){
      if(k&1) res=res*a;
      a=a*a;
      k>>=1;
    }
    return res.x;
  }
  unsigned inverse(Int_ a){
    return mpow(a,mod-2);
  }
  Int_(): x(0) { }
  Int_(long long sig) {
    int sigt=sig%mod;
    if(sigt<0) sigt+=mod;
    x=sigt;
  }
  unsigned get() const { return (unsigned)x; }
  
  Int_ &operator+=(Int_ that) { if((x += that.x) >= mod) x -= mod; return *this; }
  Int_ &operator-=(Int_ that) { if((x += mod - that.x) >= mod) x -= mod; return *this; }
  Int_ &operator*=(Int_ that) { x = (unsigned long long)x * that.x % mod; return *this; }
  Int_ &operator=(Int_ that) { x=that.x; return *this;}
  Int_ &operator/=(Int_ that) { x=(unsigned long long) x * inverse(that.x)%mod; return *this;}
  bool operator==(Int_ that) const { return x==that.x; }
  bool operator!=(Int_ that) const { return x!=that.x; }

  Int_ operator-() const { return Int_(0)-Int_(*this);}
  Int_ operator+(Int_ that) const { return Int_(*this) += that; }
  Int_ operator-(Int_ that) const { return Int_(*this) -= that; }
  Int_ operator*(Int_ that) const { return Int_(*this) *= that; }
  Int_ operator/(Int_ that) const { return Int_(*this) /= that; }
  Int_ inv(){
    return Int_(mpow(x,mod-2));
  }
};

namespace std{
  template<lint mod>
  ostream &operator <<(ostream& out,const Int_<mod>& a){
    out<<a.get();
    return out;
  }
  template<lint mod>
  istream &operator >>(istream& in,Int_<mod>& a){
    in>>a.x;
    return in;
  }
};

typedef Int_<1000000007> Int;

Int mpow(Int a,lint k){
  Int res=1;
  while(k){
    if(k&1) res=res*a;
    a=a*a;
    k>>=1;
  }
  return res;
}


//const int INF=5e8;

int n,K,m;
int ar[30005],br[30005];

Int dpL[30005][405],dpR[30005][405];

int nxt[30005],last[405];

void doit(Int dp[30005][405],int sj){
  dp[0][sj]=1;
  for(int i=0;i<n;++i){
    Int sum[405]={0};
    REP(j,K) sum[j+1]=sum[j]+dp[i][j];
    REPN(j,K,1) {
      dp[i+1][j]=sum[K]-sum[j];
    }
    REPN(j,K,1){
      dp[i+1][j+1]+=dp[i][j]*(K-j);
    }
  }
}
Int fact[30005];
Int doit2(Int pat[30005][405],Int dp[30005][405]){
  pat[1][1]=K;
  dp[1][1]=(m==1?K:0);
  REPN(i,n,1){
    Int sum1[405]={0},sum2[405]={0};
    REP(j,K){
      sum1[j+1]=sum1[j]+pat[i][j];
      sum2[j+1]=sum2[j]+dp[i][j];
    }

    REPN(j,K,1){
      pat[i+1][j]=sum1[K]-sum1[j];
      dp[i+1][j]=sum2[K]-sum2[j];
    }
    REPN(j,K,1){
      pat[i+1][j+1]+=pat[i][j]*(K-j);
      dp[i+1][j+1]+=dp[i][j]*(K-j);
    }
    REP(j,K) if(j>=m){
      dp[i+1][j]+=pat[i+1][j];
    }
  }
  Int all=mpow(K,n-m)*(n-m+1);
  Int res=0;
  REP(i,K) {
    res+=dp[n][i];
  }
  res/=fact[K]/fact[K-m];
  return all-res;
}
int main(){
  fact[0]=1;
  REP(i,30000) fact[i+1]=fact[i]*(i+1);
  cin>>n>>K>>m;
  REP(i,m) cin>>ar[i],--ar[i];

  multiset<int> prv;
  REP(i,K){
    last[i]=-1;
    prv.insert(last[i]);
  }
  bool ok=false;
  REP(i,m){
    prv.erase(prv.find(last[ar[i]]));
    last[ar[i]]=i;
    prv.insert(i);
    if(i>=K-1 && *prv.begin()>=i-(K-1)){
      ok=true;
    }
  }

  if(ok){
    Int res=mpow(K,n-m)*(n-m+1);
    cout<<res<<endl;
    return 0;
  }
  int Llen=-1,Rlen=-1;
  set<int> SL,SR;
  REP(i,m){
    if(SL.count(ar[i])){
      if(Llen==-1) Llen=i;
    }else{
      SL.insert(ar[i]);
    }

    if(SR.count(ar[m-1-i])){
      if(Rlen==-1) Rlen=i;
    }else{
      SR.insert(ar[m-1-i]);
    }
  }
  dump(Llen);dump(Rlen);
  if(Llen==-1){
    Int res=doit2(dpL,dpR);
    cout<<res<<endl;
    return 0;
  }
  doit(dpL,Llen);
  doit(dpR,Rlen);

  Int res=0;
  REP(i,n-m+1){
    int L=i,R=n-m-i;
    Int tmp=mpow(K,n-m);
    Int Lsum=0,Rsum=0;
    REP(j,K) Lsum+=dpL[L][j];
    REP(k,K) Rsum+=dpR[R][k];
    res+=tmp-Lsum*Rsum;
  }
  cout<<res<<endl;


  return 0;
}





Measured memory_bytes: 95488