#include <bits/stdc++.h>
using namespace std;
vector<bool> visited;
vector<int> color;
vector<vector<int>> adj_list;
int n, m;
map<int, set<int>> colormap;
void maxdiversity(int i) {
  visited[i] = 1;
  pair<map<int, set<int>>::iterator, bool> p =
      colormap.insert(make_pair(color[i], set<int>()));
  for (int j = 0; j < (int)adj_list[i].size(); j++) {
    int v = adj_list[i][j];
    if (color[v] != color[i]) (p.first->second).insert(color[v]);
  }
  for (int k = 0; k < (int)adj_list[i].size(); k++) {
    if (!visited[adj_list[i][k]]) {
      maxdiversity(adj_list[i][k]);
    }
  }
}
int main() {
  cin >> n >> m;
  visited.resize(n + 1);
  color.resize(n + 1);
  adj_list.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> color[i];
  int a, b;
  for (int j = 0; j < m; j++) {
    cin >> a >> b;
    adj_list[a].push_back(b);
    adj_list[b].push_back(a);
  }
  int ans = 0;
  int m = -1;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) maxdiversity(i);
  }
  for (map<int, set<int>>::iterator it = colormap.begin(); it != colormap.end();
       it++) {
    if ((int)(it->second).size() > m) {
      m = (int)(it->second).size();
      ans = it->first;
    } else {
      if ((int)(it->second).size() == m) {
        if (it->first < ans) ans = it->first;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
