#include <bits/stdc++.h>
using namespace std;
vector<int> g[200009];
int c[200009];
set<int> col[200009];
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  int fans = 1e6;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    fans = min(fans, c[i]);
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    int id = c[i];
    for (int j = 0; j < g[i].size(); j++) {
      if (c[g[i][j]] != id) {
        col[id].insert(c[g[i][j]]);
      }
    }
  }
  int maxx = -1, maxid = -1;
  for (int i = 1; i <= 100000; i++) {
    int sz = col[i].size();
    if (maxx < sz) {
      maxx = sz;
      maxid = i;
    }
  }
  if (maxx == 0) {
    maxid = fans;
  }
  printf("%d\n", maxid);
  return 0;
}
