#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int> > G;
  vector<pair<int, int> > C;
  vector<int> T(0);
  for (int i = 0; i <= n; i++) G.push_back(T);
  int d;
  C.push_back(make_pair(0, 0));
  T.push_back(0);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d);
    C.push_back(make_pair(d, i));
    T.push_back(d);
  }
  sort(C.begin(), C.end());
  int x, y;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
  int maxdiv = -1;
  int ans;
  for (int i = 1; i <= n;) {
    int div = 0;
    int color = C[i].first;
    set<int> neigh;
    set<int>::iterator it;
    vector<int> vert;
    while (C[i].first == color) {
      vert.push_back(C[i].second);
      i++;
    }
    for (int j = 0; j < vert.size(); j++) {
      for (int k = 0; k < G[vert[j]].size(); k++) {
        int sebelah = G[vert[j]][k];
        if (T[sebelah] != color) {
          neigh.insert(T[sebelah]);
        }
      }
    }
    div = neigh.size();
    if (maxdiv < div) {
      maxdiv = div;
      ans = color;
    }
  }
  printf("%d\n", ans);
  return 0;
}
