#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 = 1e5;
int a[N + 10], c[N + 10];
map<pair<int, int>, bool> ma;
int main() {
  int n, m, x, y, res = 0, col = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    if (col == 0 || col > a[i + 1]) col = a[i + 1];
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (!ma[make_pair(a[y], a[x])] && a[x] != a[y]) c[a[x]]++;
    ma[make_pair(a[y], a[x])] = 1;
    if (!ma[make_pair(a[x], a[y])] && a[x] != a[y]) c[a[y]]++;
    ma[make_pair(a[x], a[y])] = 1;
    if (c[a[y]] > res) {
      res = c[a[y]];
      col = a[y];
    } else if (c[a[y]] == res) {
      col = min(col, a[y]);
    }
    if (c[a[x]] > res) {
      res = c[a[x]];
      col = a[x];
    } else if (c[a[x]] == res) {
      col = min(col, a[x]);
    }
  }
  cout << col << endl;
  return 0;
}
