#include <bits/stdc++.h>
using namespace std;
set<int> st[100009];
int n, m, color[100009], mini;
void input() {
  int i, j, a, b, ca, cb;
  cin >> n >> m;
  mini = 2 * 100000;
  for (i = 0; i < n; ++i) {
    cin >> color[i];
    mini = min(mini, color[i]);
  }
  for (i = 0; i < m; ++i) {
    cin >> a >> b;
    --a;
    --b;
    ca = color[a];
    cb = color[b];
    if (ca != cb) st[ca].insert(cb), st[cb].insert(ca);
  }
}
void output() {
  int i, max_idx, max_size = 0;
  for (i = 0; i < 100009; ++i) {
    if (max_size < st[i].size()) {
      max_size = st[i].size();
      max_idx = i;
    }
  }
  if (max_size == 0)
    cout << mini;
  else
    cout << max_idx;
}
int main() {
  int i, j;
  input();
  output();
  return 0;
}
