#include<algorithm>#include<iostream>#include<cstring>#include<cstdio>#include<cmath>using namespace std;#define N 50005int n,m;int food[N],head[N],pre[N],tail[N],nxt[N],pos[N],cnt[N],f[N];int main(){ scanf("%d%d",&n,&m); for (int i=1;i<=n;++i) scanf("%d",&food[i]); for (int i=1;i<=n;++i) pre[i]=-1,nxt[i]=n+1; for (int i=n;i>=1;--i) { if (head[food[i]]) pre[head[food[i]]]=i; head[food[i]]=i; } for (int i=1;i<=n;++i) { if (tail[food[i]]) nxt[tail[food[i]]]=i; tail[food[i]]=i; } memset(f,127,sizeof(f));f[0]=0; for (int i=1;i<=n;++i) { for (int j=1;j*j<=n;++j) if (pre[i]<=pos[j]) ++cnt[j]; for (int j=1;j*j<=n;++j) if (cnt[j]>j) { ++pos[j]; while (nxt[pos[j]]<=i) ++pos[j]; --cnt[j]; } for (int j=1;j*j<=n;++j) f[i]=min(f[i],f[pos[j]]+j*j); } printf("%d/n",f[n]);}