#include<bits/stdc++.h>
#define il inline
#define reg register int
#define numb (ch^'0')
using namespace std;
typedef long long ll;
il void rd(int &x){
char ch;bool fl=false;
while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
for(x=numb;isdigit(ch=getchar());x=x*+numb);
(fl==true)&&(x=-x);
}
namespace Miracle{
const int N=4e5+;
int n,m;
struct node{
int nxt,to;
}e[*N];
int hd[N],cnt;
void add(int x,int y){
e[++cnt].nxt=hd[x];
e[cnt].to=y;
hd[x]=cnt;
}
int dfn[N],low[N],df,dfn2[N];
int co[N],b[N],dcc;
vector<int>mem[N];
ll preno;
vector<int>be[N];
int typ[N];//1:yuan 0:fang
int sta[N],top;
void tarjan(int x){
dfn[x]=low[x]=++df;
sta[++top]=x;
for(reg i=hd[x];i;i=e[i].nxt){
int y=e[i].to;
if(!dfn[y]){
tarjan(y);
low[x]=min(low[x],low[y]);
if(low[y]>=dfn[x]){
++dcc;
int z;
do{
z=sta[top];
mem[dcc].push_back(z);
--top;
}while(z!=y);
mem[dcc].push_back(x);
}
}else low[x]=min(low[x],dfn[y]);
}
}
void dfs1(int x){
dfn[x]=++df;
for(reg i=hd[x];i;i=e[i].nxt){
int y=e[i].to;
if(!dfn[y])dfs1(y);
}
dfn2[x]=df;
}
ll dp[N];
ll tag[N]; void dfs2(int x){ }
ll ans[N]; void sol(int x){ }
int main(){
rd(n);rd(m);
int tot=;
for(reg i=;i<=n;++i) rd(co[i]),b[++tot]=co[i];
sort(b+,b+tot+);
tot=unique(b+,b+tot+)-b-;
for(reg i=;i<=n;++i){
co[i]=lower_bound(b+,b+tot+,co[i])-b;
be[co[i]].push_back(i);
}
for(reg i=;i<=n;++i){
if(!dfn[i]) tarjan(i);
}
memset(hd,,sizeof hd);
memset(dfn,,sizeof dfn);
df=;cnt=;
int tot=n;
for(reg i=;i<=dcc;++i){
++tot;
typ[tot]=;
for(reg j=;j<(int)mem[i].size();++j){
typ[mem[i][j]]=;
add(tot,mem[i][j]);
add(mem[i][j],tot);
}
}
for(reg i=;i<=tot;++i){
if(!dfn[i]){
dfs1(i);
}
} for(reg i=;i<=)
} }
signed main(){
Miracle::main();
return ;
} /*
Author: *Miracle*
Date: 2019/2/19 17:48:21
*/