#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
set<long long> col[N];
long long c[N];
int main() {
  long long n, m, i, v, u, mxsz, mxid;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> c[i];
  while (m--) {
    cin >> v >> u;
    if (c[v] == c[u]) continue;
    col[c[v]].insert(c[u]);
    col[c[u]].insert(c[v]);
  }
  sort(c + 1, c + n + 1);
  mxsz = mxid = -1;
  for (i = 1; i <= n; i++) {
    if (mxsz < col[c[i]].size()) {
      mxsz = col[c[i]].size();
      mxid = c[i];
    }
  }
  cout << mxid << "\n";
  return 0;
}
