#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-7;
int c[100005];
set<int> GG[100005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int max_c = 0;
  pair<int, int> ans = make_pair(0, 1 << 29);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    max_c = max(max_c, c[i]);
    ans.second = min(ans.second, c[i]);
  }
  while (m--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (c[a] != c[b]) {
      GG[c[a]].insert(c[b]);
      GG[c[b]].insert(c[a]);
    }
  }
  for (int cc = 1; cc <= max_c; cc++)
    if (((int)(GG[cc]).size()) > ans.first) {
      ans.first = ((int)(GG[cc]).size());
      ans.second = cc;
    }
  printf("%d\n", ans.second);
  return 0;
}
