#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m, a, b;
  cin >> n >> m;
  vector<int> colors;
  vector<set<int>> pairings;
  colors.resize(n + 1);
  pairings.resize(1e5 + 10);
  for (int i = 1; i <= n; ++i) {
    cin >> colors[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    if (colors[a] != colors[b]) pairings[colors[a]].insert(colors[b]);
    if (colors[a] != colors[b]) pairings[colors[b]].insert(colors[a]);
  }
  int maxSet = -1;
  int minColor = 1e9;
  for (int i = 1; i <= n; ++i) {
    maxSet = max(maxSet, (int)pairings[colors[i]].size());
  }
  for (int i = 1; i <= n; ++i) {
    if (maxSet == (int)pairings[colors[i]].size()) {
      minColor = min(minColor, colors[i]);
    }
  }
  cout << minColor << endl;
  return 0;
}
