#include <bits/stdc++.h>
using namespace std;
ifstream in("input.txt");
ofstream out("output.txt");
vector<int> v[500001];
vector<vector<int>> v2(101), g2(101);
vector<pair<int, int>> vi[100001];
set<int> s[500001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, l = INT_MAX;
  cin >> n >> m;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    l = min(l, a[i]);
  }
  while (m--) {
    int x, y;
    cin >> x >> y;
    if (a[x] != a[y]) {
      s[a[x]].insert(a[y]);
      s[a[y]].insert(a[x]);
    }
  }
  int ma = 0;
  for (int i = 1; i <= n; i++) {
    if (ma < s[a[i]].size()) {
      ma = s[a[i]].size();
      l = a[i];
    } else if (ma == s[a[i]].size())
      l = min(l, a[i]);
  }
  cout << l << endl;
  return 0;
}
