#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 5;
long long c[N], deg[N];
set<long long> nc[N];
vector<long long> g[N];
bool vis[N];
void dfs(long long u) {
  vis[u] = true;
  for (long long v : g[u]) {
    if (!vis[v]) {
      dfs(v);
      nc[c[u]].insert(c[v]);
    } else
      nc[c[u]].insert(c[v]);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  set<long long> allColors;
  for (long long i = 1; i <= n; i++) {
    cin >> c[i];
    vis[i] = false;
    nc[i].clear();
    allColors.insert(c[i]);
  }
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i);
  }
  long long mx = -1, color = 1;
  for (long long i : allColors) {
    long long sz = nc[i].size();
    if (nc[i].find(i) != nc[i].end()) {
      sz--;
    }
    if (sz > mx) {
      mx = sz;
      color = i;
    }
  }
  cout << color;
  return 0;
}
