#include <bits/stdc++.h>
using namespace std;
int c[100005];
set<int> nc[100005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (c[x] != c[y]) {
      nc[c[x]].insert(c[y]);
      nc[c[y]].insert(c[x]);
    }
  }
  int r = 0;
  for (int i = 1; i <= n; i++) {
    if (nc[c[i]].size() > nc[r].size() || i == 1 ||
        (nc[r].size() == nc[c[i]].size() && c[i] < r))
      r = c[i];
  }
  cout << r;
  return 0;
}
