#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
set<int> s[maxn];
bool vis[maxn];
int clo[maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) s[i].clear();
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &clo[i]);
    vis[clo[i]] = 1;
  }
  int u, v;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    if (clo[u] != clo[v]) {
      s[clo[u]].insert(clo[v]);
      s[clo[v]].insert(clo[u]);
    }
  }
  int mm = -1;
  int ret = 0;
  for (int i = 1; i < maxn; i++) {
    if (vis[i] && mm < (int)s[i].size()) {
      mm = (int)s[i].size();
      ret = i;
    }
  }
  printf("%d\n", ret);
  return 0;
}
