#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 100;
set<int> arr[maxN];
int n, m, u, v, out, c[maxN], s;
int main() {
  scanf("%d", &n), scanf("%d", &m);
  for (int i = 0; i < n; ++i) scanf("%d", &c[i + 1]);
  out = *min_element(c + 1, c + n + 1);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &u), scanf("%d", &v);
    if (c[u] == c[v]) continue;
    arr[c[u]].insert(c[v]);
    arr[c[v]].insert(c[u]);
  }
  for (int i = 0; i < maxN; ++i) {
    if (arr[i].size() > s) {
      out = i;
      s = arr[i].size();
    }
  }
  cout << out << endl;
}
