#include <bits/stdc++.h>
using namespace std;
set<int> s[100005];
int color[100005];
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    int i, j, tmp = 0;
    int u, v, ans;
    for (i = 1; i <= n; i++) scanf("%d", &color[i]);
    for (j = 0; j < m; j++) {
      scanf("%d%d", &u, &v);
      if (color[u] != color[v]) {
        s[color[v]].insert(color[u]);
        s[color[u]].insert(color[v]);
      }
    }
    ans = color[1];
    for (i = 1; i <= n; i++) {
      if (s[color[i]].size() > tmp ||
          (s[color[i]].size() == tmp && color[i] < ans)) {
        tmp = s[color[i]].size();
        ans = color[i];
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
