#include <bits/stdc++.h>
using namespace std;
void addEdge(vector<int> adj[], int u, int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
int main() {
  int v, edges, point1, point2, number, i;
  cin >> v >> edges;
  vector<int> vertices;
  set<int> answer[100001];
  bool present[100001] = {false};
  for (i = 0; i < v; i++) {
    cin >> number;
    vertices.push_back(number);
    present[number] = true;
  }
  for (i = 0; i < edges; i++) {
    cin >> point1 >> point2;
    int color1 = vertices[point1 - 1];
    int color2 = vertices[point2 - 1];
    if (color2 != color1) {
      answer[color1].insert(color2);
      answer[color2].insert(color1);
    }
    present[color1] = true;
    present[color2] = true;
  }
  int max, maxIndex;
  for (i = 0; i < 100001 && present[i] == false; i++)
    ;
  if (i < 100001) {
    max = answer[i].size();
    maxIndex = i;
  }
  for (i = maxIndex; i < 100001; i++) {
    if (answer[i].size() > max && present[i] == true) {
      maxIndex = i;
      max = answer[i].size();
    }
  }
  cout << maxIndex;
}
