#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 1e9 + 7;
int n, m, c[N], vis[N], maxi, minic = 1e9, ans;
stack<int> col[N], eras;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> c[i], minic = min(minic, c[i]);
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    col[c[u]].push(c[v]);
    col[c[v]].push(c[u]);
  }
  for (int i = 0; i < N; i++) {
    vis[i] = 1;
    int curr = 0;
    while (!col[i].empty()) {
      if (vis[col[i].top()] == 0) curr++, vis[col[i].top()] = 1;
      eras.push(col[i].top());
      col[i].pop();
    }
    while (!eras.empty()) vis[eras.top()] = 0, eras.pop();
    if (curr > maxi) maxi = curr, ans = i;
    vis[i] = 0;
  }
  if (maxi)
    cout << ans << endl;
  else
    cout << minic << endl;
  return 0;
}
