#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i;
  cin >> n >> m;
  vector<int> colour;
  vector<int> graph[n + 2];
  int x;
  set<int> s2;
  for (i = 0; i < n; i++) {
    cin >> x;
    colour.push_back(x);
    s2.insert(x);
  }
  int p = *max_element(colour.begin(), colour.end());
  set<int> dp2[p + 2];
  int a, b;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      dp2[colour[i - 1]].insert(colour[graph[i][j] - 1]);
    }
  }
  int ans[*max_element(colour.begin(), colour.end()) + 1];
  for (i = 1; i <= p; i++) {
    if (dp2[i].find(i) != dp2[i].end()) {
      ans[i] = dp2[i].size() - 1;
    } else {
      ans[i] = dp2[i].size();
    }
  }
  int fv = -1;
  int z = -1;
  for (i = 1; i <= p; i++) {
    if (s2.find(i) != s2.end() && ans[i] > fv) {
      fv = ans[i];
      z = i;
    }
  }
  cout << z;
  return 0;
}
