#include <bits/stdc++.h>
using namespace std;
int color[100005];
set<int> arr[100005];
bool valid[100005];
int main() {
  int N, M, num1, num2;
  cin >> N >> M;
  for (int i = 0; i < 100005; i += 1) arr[i].insert(i), valid[i] = false;
  for (int i = 0; i < N; i += 1) cin >> color[i], valid[color[i]] = true;
  for (int i = 0; i < M; i += 1) {
    cin >> num1 >> num2;
    num1--, num2--;
    num1 = color[num1], num2 = color[num2];
    if (num1 != num2) arr[num1].insert(num2), arr[num2].insert(num1);
  }
  int ans = -1, idx;
  for (int i = 1; i < 100005; i += 1) {
    int size = arr[i].size();
    if (size > ans && valid[i]) ans = size, idx = i;
  }
  cout << idx << endl;
}
