#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)(1e5 + 5);
int n, m, c[MAXN];
set<int> colors;
set<int> adj[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
    colors.insert(c[i]);
  }
  for (int i = 0, a, b; i < m; ++i) {
    cin >> a >> b;
    if (c[a] == c[b]) continue;
    adj[c[a]].insert(c[b]);
    adj[c[b]].insert(c[a]);
  }
  int ans;
  int curMax = -1;
  for (set<int>::iterator it = colors.begin(); it != colors.end(); it++) {
    int curC = (*it);
    if ((int)(adj[curC].size()) > curMax) {
      ans = curC;
      curMax = adj[curC].size();
    }
  }
  cout << ans << '\n';
  return 0;
}
