#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int c[N];
set<int> sets[N];
bool vis[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", c + i);
    vis[c[i]] = 1;
  }
  while (m--) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    if (c[u] != c[v]) {
      sets[c[u]].insert(c[v]);
      sets[c[v]].insert(c[u]);
    }
  }
  int color = 1, best = -1;
  for (int c = 1; c < N; ++c) {
    if (vis[c] && (int)sets[c].size() > best) {
      best = sets[c].size();
      color = c;
    }
  }
  printf("%d\n", color);
}
