#include <bits/stdc++.h>
using namespace std;
vector<int> v[100007];
vector<int> vv[100007];
int a[100007];
int b[100007];
int vis[100007];
int dfs(int pos) {
  vis[pos] = 1;
  int i;
  for (i = 0; i < v[pos].size(); i++) {
    if (a[v[pos][i]] != a[pos]) vv[a[pos]].push_back(a[v[pos][i]]);
    if (!vis[v[pos][i]]) dfs(v[pos][i]);
  }
  return 0;
}
int main() {
  int m, p;
  scanf("%d %d", &m, &p);
  int i;
  for (i = 1; i <= m; i++) scanf("%d", a + i), b[a[i]] = 1;
  for (i = 0; i < p; i++) {
    int from, to;
    scanf("%d %d", &from, &to);
    v[from].push_back(to), v[to].push_back(from);
  }
  for (i = 1; i <= m; i++)
    if (!vis[i]) dfs(i);
  int ans = 0;
  for (i = 1; i <= 1e5; i++) {
    sort(vv[i].begin(), vv[i].end());
    vv[i].resize(unique(vv[i].begin(), vv[i].end()) - vv[i].begin());
    if (b[i] && (vv[i].size() > vv[ans].size() || !ans)) ans = i;
  }
  printf("%d\n", ans);
  return 0;
}
