#include <bits/stdc++.h>
using namespace std;
inline void normal(long long int& a) { a = (a + 1000000007) % 1000000007; }
inline int modMul(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline int modAdd(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline int modSub(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline int modPow(long long int b, long long int p) {
  int r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline int modInv(int a) { return modPow(a, 1000000007 - 2); }
inline int modDiv(int a, int b) { return modMul(a, modInv(b)); }
inline int fact(int r) {
  int ans = 1;
  while (r) ans = modMul(ans, r), r--;
  return ans;
}
inline int invfact(int r) {
  int ans = 1;
  while (r) ans = modMul(ans, modInv(r)), r--;
  return ans;
}
inline double dgcd(double a, double b) {
  if (a < b) return dgcd(b, a);
  if (b < .0001) return a;
  return dgcd(b, fmod(a, b));
}
const long long int N = 1e5 + 2;
const long long int INF = 1e17;
clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& q) {
  in >> q.first >> q.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& q) {
  out << q.first << " " << q.second;
  return out;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2) {
  return {p1.first + p2.first, p1.second + p2.second};
}
template <typename T1, typename T2>
pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2) {
  return {p1.first - p2.first, p1.second - p2.second};
}
long long int power(long long int base, long long int exp) {
  long long int res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % 1000000007;
    base = (base * base) % 1000000007;
    exp /= 2;
  }
  return res % 1000000007;
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
vector<long long int> v[N];
bool vis[N] = {false};
long long int c[N];
set<long long int> ss;
map<long long int, set<long long int> > ms;
void dfs(long long int x) {
  vis[x] = true;
  for (long long int i : v[x]) {
    if (c[i] != c[x]) ms[c[x]].insert(c[i]);
    if (!vis[i]) dfs(i);
  }
  ss.insert(c[x]);
}
void Timelimitexceeded() {
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 1; i < n + 1; i++) cin >> c[i];
  for (long long int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (long long int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  long long int ans = -1, res;
  for (long long int x : ss) {
    if ((long long int)((ms[x]).size()) > ans)
      ans = (long long int)((ms[x]).size()), res = x;
  }
  cout << res << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  clock_t start, end;
  start = clock();
  cout << fixed << setprecision(11);
  while (t--) {
    Timelimitexceeded();
  }
  end = clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
}
