/*
题意:有一个无向简单图,每个定点有一个颜色编号,求相邻颜色种类数最多的颜色的编号是多少
如果有多个满足条件的输出最小编号
*/
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
const int maxn = 1e5+5;
vector<int>G[maxn];
int c[maxn];
vector<int>clo[maxn];
set<int>cnt[maxn];
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
scanf("%d",&c[i]);
clo[c[i]].push_back(i);
}
for(int i=1;i<=m;i++){
int u,v;
scanf("%d%d",&u,&v);
G[u].push_back(v);
G[v].push_back(u);
}
int ans=0;
for(int i=1;i<maxn;i++){
int len=clo[i].size();
for(int j=0;j<len;j++){
int u=clo[i][j];
int len1=G[u].size();
for(int k=0;k<len1;k++){
int v=G[u][k];
cnt[i].insert(c[v]);
}
cnt[i].insert(c[u]);
}
ans=max(ans,(int)cnt[i].size()-1);
}
for(int i=1;i<maxn;i++){
if(cnt[i].size()-1==ans){
printf("%d\n",i);
break;
}
}
return 0;
}