#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> col(n);
  for (long long i = 0; i < n; i++) cin >> col[i];
  map<long long, set<long long>> adj;
  for (auto cl : col) {
    adj[cl] = set<long long>();
  }
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    u -= 1;
    v -= 1;
    if (col[u] != col[v]) {
      adj[col[u]].insert(col[v]);
      adj[col[v]].insert(col[u]);
    }
  }
  long long mx = 0;
  long long ans = INT_MAX;
  for (auto el : adj) {
    mx = max(mx, (long long)(el.second.size()));
  }
  for (auto el : adj) {
    if ((long long)(el.second.size()) == mx) {
      ans = min(ans, el.first);
    }
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
