#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const double EPS = 10e-9;
const int MAXN = 100005;
const int MAXC = 100005;
int c[MAXN];
vector<int> cv[MAXC];
vector<int> t[MAXN];
bool visC[MAXC];
int visCC[MAXC];
int vis[MAXN];
void rob() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (typeof(0) i = (0); i < (n); ++i) {
    scanf("%d", &c[i]);
    cv[c[i]].push_back(i);
  }
  int a, b;
  for (typeof(0) i = (0); i < (m); ++i) {
    scanf("%d %d", &a, &b);
    --a;
    --b;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  int res = -1;
  int resCol = -1;
  for (typeof(0) i = (0); i < (n); ++i) {
    if (!visC[c[i]]) {
      int col = c[i];
      visC[col] = 1;
      visCC[col] = col;
      int count = 0;
      for (typeof((cv[col]).begin()) v = ((cv[col]).begin());
           v != (cv[col]).end(); ++v) {
        for (typeof((t[*v]).begin()) w = ((t[*v]).begin()); w != (t[*v]).end();
             ++w) {
          if (visCC[c[*w]] != col) {
            visCC[c[*w]] = col;
            ++count;
          }
        }
      }
      if (res < count || (res == count && resCol > col)) {
        res = count;
        resCol = col;
      }
    }
  }
  printf("%d\n", resCol);
}
int main() {
  int test = 1;
  while (test--) rob();
  return 0;
}
