#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  cin >> n >> m;
  vector<int> v[n + 1];
  int a[n + 1];
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  vector<map<int, int>> mm(100001);
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      if (a[v[i][j]] != a[i]) mm[a[i]][a[v[i][j]]]++;
    }
  }
  int max = 0, maxi = 0;
  for (int i = 1; i <= n; ++i) {
    if (mm[a[i]].size() >= max) {
      max = mm[a[i]].size();
      maxi = i;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (max == mm[a[i]].size()) {
      if (a[i] < a[maxi]) {
        maxi = i;
      }
    }
  }
  cout << a[maxi] << endl;
}
