#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 1e5 + 5;
int n, m, c[N];
set<int> g[N];
void code() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (c[b] != c[a]) {
      g[c[a]].insert(c[b]);
      g[c[b]].insert(c[a]);
    }
  }
  int ans = 0, mx = 0;
  for (int i = 1; i < N; i++) {
    if (!g[i].size()) continue;
    if (g[i].size() > mx) {
      mx = g[i].size();
      ans = i;
    }
  }
  cout << (ans == 0 ? *min_element(c + 1, c + n + 1) : ans) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  while (t-- > 0) {
    code();
  }
}
