#include <bits/stdc++.h>
int main() {
  int n, m, color[100001], x, y, max;
  std::vector<std::set<int>> s(100001);
  std::cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    std::cin >> color[i];
    s[color[i]].insert(color[i]);
  }
  for (int i = 0; i < m; ++i) {
    std::cin >> x >> y;
    if (color[x] != color[y]) {
      s[color[x]].insert(color[y]);
      s[color[y]].insert(color[x]);
    }
  }
  max = 0;
  for (int i = 1; i < 100001; ++i)
    if (s[i].size() > s[max].size()) max = i;
  std::cout << max;
  return 0;
}
