#include <bits/stdc++.h>
using namespace std;
int C[100005], A[100005];
map<int, int> M[100005];
bool flag[100005];
int main() {
  int m, n, u, v, i, mx = 0, ans, cm = 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%d", C + 1 + i);
  for (i = 1; i <= n; i++) cm = max(cm, C[i]), flag[C[i]] = true;
  while (m--) {
    scanf("%d%d", &u, &v);
    if (C[u] != C[v] && M[C[u]].count(C[v]) == 0) M[C[u]][C[v]] = 1;
    if (C[u] != C[v] && M[C[v]].count(C[u]) == 0) M[C[v]][C[u]] = 1;
    mx = max(mx, max((int)M[C[u]].size(), (int)M[C[v]].size()));
  }
  for (i = 1; i <= cm; i++) {
    if (flag[i] && M[i].size() == mx) break;
  }
  printf("%d", i);
  return 0;
}
