#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int n, m, i, c[100005], a, b, v, k, t[100005];
set<int> g[100005];
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> c[i], t[c[i]]++;
  for (i = 1; i <= m; i++) {
    cin >> a >> b;
    if (c[a] != c[b]) g[c[a]].insert(c[b]), g[c[b]].insert(c[a]);
  }
  for (i = 1e5 + 3; i >= 1; i--)
    if (v <= g[i].size() && t[i]) k = i, v = g[i].size();
  cout << k;
  return 0;
}
