#include <bits/stdc++.h>
using namespace std;
set<int> s[112345];
bool k[112345];
int c[112345];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    k[c[i]] = true;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (c[x] != c[y]) {
      s[c[x]].insert(c[y]);
      s[c[y]].insert(c[x]);
    }
  }
  int mx = 0;
  for (int i = 1; i <= (int)1e5; i++) mx = max(mx, (int)s[i].size());
  int ans = 1;
  while (s[ans].size() != mx || k[ans] == false) ans++;
  cout << ans << "\n";
  return 0;
}
