#include <bits/stdc++.h>
using namespace std;
int col[100001] = {0};
vector<int> v[100001];
set<int> s[100001];
void dfs(int ver) {
  for (int i = 0; i < v[ver].size(); i++) {
    int p = col[v[ver][i]];
    if (p != col[ver]) s[col[ver]].insert(p);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int ver1 = INT_MAX;
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
    ver1 = min(ver1, col[i]);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int ans = INT_MIN;
  for (int i = 1; i <= n; i++) dfs(i);
  for (int i = 1; i <= n; i++) {
    int k = s[col[i]].size();
    if (k > ans) {
      ver1 = col[i];
      ans = k;
    }
    if (k == ans) {
      ver1 = min(ver1, col[i]);
    }
  }
  cout << ver1;
  return 0;
}
