#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
const int maxn = 100 * 1000 + 10;
vector<int> g[maxn];
set<int> v[maxn];
set<int> q[maxn];
int c[maxn];
int main() {
  int max = 0, min = 1000 * 1000 * 1000;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    if (c[i] > max) max = c[i];
    if (c[i] < min) min = c[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    if (c[a] != c[b]) {
      q[c[a]].insert(c[b]);
      q[c[b]].insert(c[a]);
    }
  }
  int ans = min, p = q[min].size();
  for (int i = min; i <= max; i++) {
    if (q[i].size() > p) {
      p = q[i].size();
      ans = i;
    }
  }
  cout << ans << endl;
}
