#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, c[maxn], ans, maxSize = -1;
set<int> adj[maxn];
bool mark[maxn];
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    mark[c[i]] = 1;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[c[u]].insert(c[v]);
    adj[c[v]].insert(c[u]);
  }
  for (int i = 0; i < maxn; i++) adj[i].erase(i);
  for (int i = 0; i < maxn; i++) {
    int Size = adj[i].size();
    if (Size > maxSize && mark[i]) {
      maxSize = Size;
      ans = i;
    }
  }
  cout << ans << endl;
}
