#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 500000 + 10;
int arr[nax], color[nax];
vector<int> graph[nax];
map<int, set<int> > map1;
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> color[i];
  while (m--) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    for (auto x : graph[i]) {
      if (color[i] != color[x]) map1[color[i]].insert(color[x]);
    }
  }
  int maxi = map1[color[1]].size(), ans = color[1];
  for (int i = 2; i <= n; i++) {
    if (map1[color[i]].size() == maxi && color[i] < ans) {
      ans = color[i];
    } else if (map1[color[i]].size() > maxi) {
      maxi = map1[color[i]].size();
      ans = color[i];
    }
  }
  cout << ans << endl;
  return 0;
}
