#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long N = 1e5 + 36;
const long long M = 11;
const long long INF = 2e18 + 7;
const long long MOD1 = 987654323;
const long long MOD = 1e9 + 7;
const long long MOD2 = 1e9 + 9;
const int XK[4] = {-1, 0, 1, 0};
const int YK[4] = {0, -1, 0, 1};
const int X[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int Y[8] = {2, -2, 2, -2, 1, -1, 1, -1};
set<int> g[N];
int a[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i(0); i < n; ++i) {
    cin >> a[i];
    g[a[i]].insert(a[i]);
  }
  for (int i(0); i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[a[x]].insert(a[y]);
    g[a[y]].insert(a[x]);
  }
  int mx = -1, ans = -1;
  for (int i(0); i < N; ++i) {
    if (mx < int(g[i].size())) {
      mx = int(g[i].size());
      ans = i;
    }
  }
  cout << ans << '\n';
  return 0;
}
