#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m) {
    int clr[100003], flag[100003];
    set<int> see[100003];
    for (int i = 1; i <= n; i++) {
      cin >> clr[i];
      flag[clr[i]] = 1;
    }
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      if (clr[u] != clr[v]) {
        see[clr[u]].insert(clr[v]);
        see[clr[v]].insert(clr[u]);
      }
    }
    int maxans = -1, ind = -1;
    for (int i = 1; i <= 1e5; i++) {
      if ((int)see[i].size() > maxans && flag[i]) {
        ind = i;
        maxans = (int)see[i].size();
      }
    }
    cout << ind << endl;
  }
}
