#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m;
int col[N];
map<int, int> ma[N];
int cnt[N];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &col[i]);
    cnt[col[i]]++;
  }
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    ma[col[u]][col[v]] = true;
    ma[col[v]][col[u]] = true;
  }
  int maxvalue = -1, maxk = 0;
  for (int i = 1; i <= 100000; i++) {
    if (ma[i].count(i)) ma[i].erase(i);
    if (cnt[i] && (int)ma[i].size() > maxvalue) {
      maxvalue = ma[i].size();
      maxk = i;
    }
  }
  printf("%d\n", maxk);
  return 0;
}
