#include <bits/stdc++.h>
using namespace std;
vector<int> col(1e5 + 10);
vector<set<int>> cols(1e5 + 10);
int main() {
  int n, m, x, y, maxc = 0, ans = 0, mincol = 1e9;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> col[i];
    if (col[i] < mincol) mincol = col[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (col[x - 1] == col[y - 1]) continue;
    cols[col[x - 1]].insert(col[y - 1]);
    cols[col[y - 1]].insert(col[x - 1]);
    if (cols[col[x - 1]].size() > maxc) {
      maxc = cols[col[x - 1]].size();
      ans = col[x - 1];
    }
    if (cols[col[y - 1]].size() > maxc) {
      maxc = cols[col[y - 1]].size();
      ans = col[y - 1];
    }
    if (cols[col[x - 1]].size() == maxc && col[x - 1] < ans) {
      maxc = cols[col[x - 1]].size();
      ans = col[x - 1];
    }
    if (cols[col[y - 1]].size() == maxc && col[y - 1] < ans) {
      maxc = cols[col[y - 1]].size();
      ans = col[y - 1];
    }
  }
  if (ans == 0)
    cout << mincol;
  else
    cout << ans;
}
