#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
long long n, m;
vector<long long> v;
vector<vector<long long> > g;
int main() {
  cin >> n >> m;
  v = vector<long long>(n + 1);
  g = vector<vector<long long> >(n + 1);
  vector<vector<long long> > col(1e5 + 1);
  for (long long i = 1; i <= n; i++) {
    cin >> v[i];
    col[v[i]].push_back(i);
  }
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<set<long long> > st(1e5 + 1);
  for (long long i = 1; i <= 1e5; i++) {
    for (auto it : col[i]) {
      for (auto j : g[it]) {
        st[i].insert(v[j]);
      }
    }
    if (st[i].find(i) != st[i].end()) {
      st[i].erase(i);
    }
  }
  vector<long long> size(1e5 + 1, 0);
  long long max1 = -1;
  long long ind = -1;
  for (long long i = 1; i <= 1e5 + 1; i++) {
    if (col[i].size() == 0) continue;
    long long store = st[i].size();
    if (store > max1) {
      max1 = store;
      ind = i;
    } else if (store == 0 && max1 == -1) {
      max1 = 0;
      ind = i;
    }
  }
  cout << ind;
  return 0;
}
