#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5;
const int INF = (int)1e9 + 9;
const int MOD = (int)1e9 + 7;
void go(int x) {
  cout << x;
  exit(0);
}
vector<int> g[N];
set<int> st[N];
int c[N];
bool used[N];
int main() {
  int n, m, cnt = -1, ans = -1;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    used[c[i]] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    used[c[u]] = 1;
    used[c[v]] = 1;
    if (c[u] == c[v]) {
      continue;
    }
    st[c[u]].insert(c[v]);
    st[c[v]].insert(c[u]);
  }
  for (int i = 1; i <= 1e5; i++) {
    if (used[i] && (int)st[i].size() > cnt) {
      cnt = (int)st[i].size();
      ans = i;
    }
  }
  cout << ans << endl;
}
