#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e5 + 1;
int n, m, ans = 0, mxsize = -1;
vector<vector<int>> adj(N);
vector<bool> visited(N);
vector<int> c(N);
map<int, set<int>> cnt;
void dfs(int v) {
  visited[v] = true;
  for (int u : adj[v]) {
    if (c[u] ^ c[v]) cnt[c[v]].insert(c[u]);
    if (!visited[u]) dfs(u);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    cnt[c[i]].clear();
  }
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[v - 1].push_back(u - 1);
    adj[u - 1].push_back(v - 1);
  }
  for (int i = 0; i < n; i++) {
    if (!visited[i]) dfs(i);
  }
  for (auto i : cnt) {
    int s = i.second.size();
    if (s > mxsize) {
      mxsize = i.second.size();
      ans = i.first;
    }
  }
  cout << ans;
}
