#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, bool> jp;
int colors[100 * 1000 + 5];
int res[100 * 1000 + 5];
vector<int> adj[100 * 1000 + 5];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, m, clr, a, b, i, j, k;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> colors[i];
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    adj[a].push_back(b), adj[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < (int)adj[i].size(); j++) {
      if (!jp[make_pair(colors[i], colors[adj[i][j]])] and
          colors[i] != colors[adj[i][j]])
        res[colors[i]]++, jp[make_pair(colors[i], colors[adj[i][j]])] = true;
    }
  }
  int maxi = 0;
  clr = 1000 * 1000 * 10;
  for (i = 1; i <= n; i++)
    if (res[colors[i]] > maxi)
      clr = colors[i], maxi = res[colors[i]];
    else if (res[colors[i]] == maxi)
      clr = min(clr, colors[i]);
  cout << clr;
  return 0;
}
