#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int col[n + 2];
  for (int i = 1; i <= n; i++) cin >> col[i];
  set<int> g[100008];
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if (col[u] != col[v]) {
      g[col[u]].insert(col[v]);
      g[col[v]].insert(col[u]);
    }
  }
  int ind = -1, mx = 0, mn = INT_MAX;
  for (int i = 1; i <= 100000; i++) {
    if (mx < g[i].size()) {
      mx = g[i].size();
      ind = i;
    }
  }
  if (ind > -1) {
    cout << ind;
    return 0;
  }
  for (int i = 1; i <= n; i++) mn = min(col[i], mn);
  cout << mn;
}
