#include <bits/stdc++.h>
using namespace std;
int n, m, c[100005];
set<int> neigbors[100005];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    neigbors[c[i]].insert(c[i]);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a -= 1;
    b -= 1;
    if (c[a] != c[b]) {
      neigbors[c[a]].insert(c[b]);
      neigbors[c[b]].insert(c[a]);
    }
  }
  int answer = 1;
  int maximum = neigbors[1].size();
  for (int i = 0; i < 100005; i++) {
    if (neigbors[i].size() > maximum) {
      answer = i;
      maximum = neigbors[i].size();
    }
  }
  cout << answer << endl;
  return 0;
}
