#include <bits/stdc++.h>
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 4611686018427387903;
const int Sz = 1110111;
using namespace std;
inline void Read_rap() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
}
int n, m;
set<int> fr[Sz];
int c[Sz];
set<int> v;
int main() {
  Read_rap();
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    v.insert(c[i]);
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (c[x] != c[y]) {
      fr[c[x]].insert(c[y]);
      fr[c[y]].insert(c[x]);
    }
  }
  int ans = 0;
  for (auto c : v)
    if (ans == 0 || (int)(fr[c].size()) > (int)(fr[ans].size())) ans = c;
  cout << ans;
  return 0;
}
