#include <bits/stdc++.h>
using namespace std;
int col[100005];
set<int> cd[100005];
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int minc = 1000000000;
  for (int i = 1; i < N + 1; i++) {
    scanf("%d", &col[i]);
    minc = min(minc, col[i]);
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (col[a] != col[b]) {
      cd[col[a]].insert(col[b]);
      cd[col[b]].insert(col[a]);
    }
  }
  int mx = minc;
  int mxcd = cd[minc].size();
  for (int i = 1; i < 100001; i++) {
    if ((int)cd[i].size() > mxcd) {
      mxcd = cd[i].size();
      mx = i;
    }
  }
  printf("%d\n", mx);
}
