#include <bits/stdc++.h>
using namespace std;
int col[110000];
bool is_present[110000];
set<int> grph[110000];
int main() {
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
    is_present[col[i]] = 1;
  }
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    if (col[u] != col[v]) {
      grph[col[u]].insert(col[v]);
      grph[col[v]].insert(col[u]);
    }
  }
  int ansindx = 0, anscnt = 0;
  for (int i = 1; i <= 1e5 + 1; i++) {
    if (grph[i].size() > anscnt) {
      ansindx = i;
      anscnt = grph[i].size();
    }
    if (ansindx == 0 && is_present[i] == 1) {
      ansindx = i;
      anscnt = grph[i].size();
    }
  }
  cout << ansindx;
  return 0;
}
