#include <bits/stdc++.h>
using namespace std;
const int MN = 100005;
int color[MN];
map<int, set<int> > M;
vector<int> g[MN];
int main() {
  int n, m;
  scanf("%d%d\n", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &color[i]);
    M[color[i]].insert(color[i]);
  }
  for (int x, y, i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int Max = 0, ans = color[1];
  for (int i = 1, j; i <= n; i++) {
    for (auto k : g[i]) M[color[i]].insert(color[k]);
  }
  for (auto s : M) {
    int len = (int)s.second.size() - (int)s.second.count(s.first);
    if (len > Max) {
      Max = len;
      ans = s.first;
    } else if (len == Max)
      ans = min(ans, s.first);
  }
  printf("%d\n", ans);
  return 0;
}
