#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, m, col[MAXN], ans;
set<int> e[MAXN];
int main() {
  ios ::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  ans = 1e9;
  for (int i = 1; i <= n; i++) cin >> col[i], ans = min(ans, col[i]);
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if (col[u] == col[v]) continue;
    e[col[u]].insert(col[v]);
    e[col[v]].insert(col[u]);
  }
  sort(col + 1, col + n + 1);
  for (int i = 1; i <= n; i++)
    if (e[ans].size() < e[col[i]].size()) ans = col[i];
  cout << ans << endl;
  return 0;
}
