#include <bits/stdc++.h>
using namespace std;
vector<int> ed[100010];
int n, k, m;
int a[100010];
int cc[100010];
bool vis[100010];
void func(int x) {
  vis[x] = 1;
  int cnt = 0, sz = ed[x].size();
  for (int j = 0; j < sz; j++) {
    int u = ed[x][j];
    if (!vis[u]) {
      cnt++;
      cc[u]++;
      func(u);
    }
  }
}
set<int> st[100010];
int mn;
int main() {
  cin >> n >> m;
  mn = INT_MAX;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  int aa, bb;
  while (m--) {
    cin >> aa >> bb;
    if (a[aa] != a[bb]) {
      st[a[aa]].insert(a[bb]);
      st[a[bb]].insert(a[aa]);
    }
  }
  int z;
  int mx = -1, pos = 1, cs;
  for (int i = mn; i <= 100000; i++) {
    z = st[i].size();
    if (z > mx) {
      mx = z;
      pos = i;
    }
  }
  cout << pos << endl;
  return 0;
}
