#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int cs, ct;
};
struct cmp {
  bool operator()(Edge const& e1, Edge const& e2) const {
    if (e1.cs != e2.cs) return e1.cs < e2.cs;
    if (e1.ct != e2.ct) return e1.ct < e2.ct;
    return false;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> col(n + 1, 0);
  for (int i = 1; i <= n; ++i) cin >> col[i];
  set<Edge, cmp> edges;
  vector<int> pc(100001, 0);
  for (int j = 0; j < m; ++j) {
    int s, t;
    cin >> s >> t;
    Edge e, ei;
    if (col[s] == col[t]) continue;
    e.cs = col[s];
    e.ct = col[t];
    ei = e;
    swap(ei.cs, ei.ct);
    if (edges.find(e) == edges.end() && edges.find(ei) == edges.end()) {
      ++pc[col[s]];
      ++pc[col[t]];
      edges.insert(e);
      edges.insert(ei);
    }
  }
  int mc = max_element(pc.begin(), pc.end()) - pc.begin();
  cout << (mc ? mc : *min_element(col.begin() + 1, col.end())) << endl;
}
