#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
const int N = 1000001;
set<int> a[N];
bool visited[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int b[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", b + i);
    visited[b[i]] = true;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (b[x - 1] != b[y - 1]) {
      a[b[x - 1]].insert(b[y - 1]);
      a[b[y - 1]].insert(b[x - 1]);
    }
  }
  int ans = -1, color = -1;
  for (int i = 0; i < N; ++i) {
    if ((int)a[i].size() > ans && visited[i]) {
      ans = (int)a[i].size();
      color = i;
    }
  }
  cout << color << endl;
  return 0;
}
