#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> c(n);
  map<int, set<int> > mp;
  for (int i = (0); i < (n); ++i) {
    cin >> c[i];
    mp[c[i]] = set<int>();
  }
  for (int i = (0); i < (m); ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (c[a] != c[b]) {
      mp[c[a]].insert(c[b]);
      mp[c[b]].insert(c[a]);
    }
  }
  int best = -1;
  int bestcnt = 0;
  for (map<int, set<int> >::iterator it = mp.begin(); it != mp.end(); it++) {
    if (best == -1 || (*it).second.size() > bestcnt) {
      best = (*it).first;
      bestcnt = (*it).second.size();
    }
  }
  cout << best;
}
