#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, m, i, a, b, mx, ans;
  long int c[100006];
  set<long int> cl;
  set<long int>::iterator it;
  set<long int> v[100006];
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> c[i];
    cl.insert(c[i]);
  }
  for (i = 1; i <= m; i++) {
    cin >> a >> b;
    if (c[a] != c[b]) {
      v[c[a]].insert(c[b]);
      v[c[b]].insert(c[a]);
    }
  }
  mx = 0;
  ans = 0;
  for (it = cl.begin(); it != cl.end(); it++) {
    if (v[(*it)].size() > mx) {
      mx = v[(*it)].size();
      ans = (*it);
    } else if (v[(*it)].size() == mx) {
      mx = v[(*it)].size();
      if ((*it) < ans) ans = (*it);
      if (ans == 0) ans = (*it);
    }
  }
  cout << ans;
  return 0;
}
