#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<int> c;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  c = vector<int>(n);
  unordered_map<int, set<int>> ma;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    if (!ma.count(c[i])) ma[c[i]] = set<int>();
  }
  adj = vector<vector<int>>(n, vector<int>());
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    if (c[a] != c[b]) {
      ma[c[a]].insert(c[b]);
      ma[c[b]].insert(c[a]);
    }
  }
  int cmax = 0, ans = c[0];
  for (auto x : ma) {
    int tmp = (int)x.second.size();
    if (tmp > cmax) {
      cmax = tmp;
      ans = x.first;
    } else if (tmp == cmax) {
      ans = min(ans, x.first);
    }
  }
  cout << ans << "\n";
  return 0;
}
