#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> c;
int cc[100001] = {0};
vector<int> graph[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int col;
    cin >> col;
    cc[i] = col;
    c.push_back({col, i});
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  sort(c.begin(), c.end());
  int pans = -1;
  int ans = -1;
  for (int i = 0; i < c.size(); i++) {
    queue<int> q;
    int pos = 0;
    for (int j = i; j < c.size(); j++) {
      if (c[j].first == c[i].first) {
        pos = j;
        q.push(c[j].second);
      } else {
        break;
      }
    }
    map<int, int> vis;
    int temp = q.size();
    for (int k = 0; k < temp; k++) {
      int top = q.front();
      q.pop();
      for (int j = 0; j < graph[top].size(); j++) {
        if (cc[graph[top][j]] != c[i].first) {
          vis[cc[graph[top][j]]]++;
        }
      }
    }
    i = pos;
    if ((int)vis.size() > ans) {
      ans = vis.size();
      pans = c[i].first;
    }
  }
  cout << pans << endl;
  return 0;
}
