#include <bits/stdc++.h>
using namespace std;
map<int, int> tab[100003];
int main(void) {
  int n, m;
  cin >> n >> m;
  int color[n + 1];
  int min = INT_MAX;
  for (int i = 1; i <= n; i++)
    cin >> color[i], min = (min < color[i] ? min : color[i]);
  while (m--) {
    int p, q;
    cin >> p >> q;
    tab[color[p]][color[q]]++;
    tab[color[q]][color[p]]++;
  }
  int cola[100002];
  for (int i = 1; i <= 100001; i++) cola[i] = tab[i].size();
  int max = INT_MIN, index;
  for (int i = 1; i <= 100001; i++) {
    if (cola[i] + (tab[i][i] ? -1 : 0) > max)
      max = cola[i] + (tab[i][i] ? -1 : 0), index = i;
  }
  if (!max)
    cout << min << endl;
  else
    cout << index << endl;
  return 0;
}
