#include <bits/stdc++.h>
using namespace std;
set<int> sets[100003];
int n, m, a, b, c[100003], ans;
int main(void) {
  cin >> n >> m;
  ans = 1000000;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    ans = min(ans, c[i]);
  }
  for (int j = 1; j <= m; j++) {
    cin >> a >> b;
    if (c[a] != c[b]) {
      sets[c[a]].insert(c[b]);
      sets[c[b]].insert(c[a]);
    }
  }
  for (int i = 1; i <= 100000; i++) {
    if (sets[i].size() > sets[ans].size()) ans = i;
  }
  cout << ans << endl;
}
