#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T mod_v(T num) {
  if (num >= 0)
    return num % 1000000007;
  else
    return (num % 1000000007 + 1000000007) % 1000000007;
}
template <class T>
T fast_pow(T n, T p) {
  if (p == 0) return 1;
  if (p % 2) {
    T g = mod_v(mod_v(n) * mod_v(fast_pow(n, p - 1)));
    return g;
  } else {
    T g = fast_pow(n, p / 2);
    g = mod_v(mod_v(g) * mod_v(g));
    return g;
  }
}
template <class T>
inline T modInverse(T n) {
  return fast_pow(n, 1000000007 - 2);
}
template <class T>
inline void debug(string S1, T S2, string S3) {
  cout << S1 << S2 << S3;
}
template <class T>
inline T in() {
  register char c = 0;
  register T num = 0;
  bool n = false;
  while (c < 33) c = getchar();
  while (c > 33) {
    if (c == '-')
      n = true;
    else
      num = num * 10 + c - '0';
    c = getchar();
  }
  return n ? -num : num;
}
vector<int> col1;
int col2[100009];
int mark[100005];
vector<int> aj_list[100009];
int n, m;
int a, b;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    col2[i] = in<int>();
    if (mark[col2[i]] == 0) {
      mark[col2[i]] = 1;
      col1.push_back(col2[i]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    aj_list[col2[a]].push_back(col2[b]);
    aj_list[col2[b]].push_back(col2[a]);
  }
  int c = 0, ans = -1;
  int s;
  sort((col1).begin(), (col1).end());
  for (int i = 0; i < ((int)col1.size()); i++) {
    sort((aj_list[col1[i]]).begin(), (aj_list[col1[i]]).end());
    if (((int)aj_list[col1[i]].size()) > 0) {
      if (aj_list[col1[i]][0] != col1[i])
        s = 1;
      else
        s = 0;
    } else
      s = 0;
    for (int j = 1; j < ((int)aj_list[col1[i]].size()); j++) {
      if (aj_list[col1[i]][j] != aj_list[col1[i]][j - 1] &&
          aj_list[col1[i]][j] != col1[i])
        s++;
    }
    if (s > ans) {
      ans = s;
      c = col1[i];
    }
  }
  printf("%d\n", c);
  return 0;
}
