#include <bits/stdc++.h>
using namespace std;
const int MM = 100010;
int N, M;
bool vis[MM];
int c[MM];
set<int> edge[MM];
void get_data() {
  int i, j, k, a, b;
  for (i = 1; i <= N; i++) {
    edge[i].clear();
    scanf("%d", &c[i]);
  }
  while (M--) {
    scanf("%d%d", &a, &b);
    if (c[b] != c[a]) {
      edge[c[a]].insert(c[b]);
      edge[c[b]].insert(c[a]);
    }
  }
}
void solve() {
  int i, j, k, mx = -1, col = 100001;
  int count;
  sort(c + 1, c + N + 1);
  for (i = 1; i <= N; i++) {
    if (mx == -1 || mx < edge[c[i]].size()) mx = edge[c[i]].size(), col = c[i];
  }
  printf("%d\n", col);
}
int main() {
  while (scanf("%d%d", &N, &M) != EOF) get_data(), solve();
  return 0;
}
