#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long fermat_inv(long long y) { return power(y, 1000000007 - 2); }
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
const long long N = 1e5;
vector<long long> adj[N + 1];
vector<long long> color[N + 1];
void solve() {
  long long n, m;
  cin >> n >> m;
  long long ma = -1;
  long long a[n + 1];
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a[i + 1] = x;
    ma = max(ma, x);
    color[x].push_back(i + 1);
  }
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  long long ans = -1, res;
  for (long long i = 0; i < ma; i++) {
    if (!color[i + 1].empty()) {
      set<long long> s;
      for (auto x : color[i + 1]) {
        for (auto y : adj[x]) {
          if (a[y] != i + 1) s.insert(a[y]);
        }
      }
      if ((long long)s.size() > ans) {
        ans = s.size();
        res = i + 1;
      }
    }
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
