#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxn = 1e5 + 5;
int col[maxn], ans[maxn];
set<int> st[maxn];
vector<int> e[maxn];
int mm;
int main() {
  cin >> n >> m;
  int nb = 0x7f7f7f7f;
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
    nb = min(nb, col[i]);
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (col[x] != col[y]) {
      st[col[x]].insert(col[y]);
      st[col[y]].insert(col[x]);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (st[col[i]].size() > st[nb].size()) {
      nb = col[i];
    }
  }
  cout << nb;
}
