#include <bits/stdc++.h>
using namespace std;
struct s {
  int x, y;
  bool operator<(const s& s1) const {
    if (x > s1.x) return false;
    if (x < s1.x) return true;
    if (y > s1.y) return false;
    return true;
  }
};
s g[200100];
int main() {
  int i, j, q, n, m, a, b, c[100100];
  int k = 0, mx = 0, ans = 0, ansc = 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    a--;
    b--;
    if (c[a] != c[b]) {
      g[k].x = c[a];
      g[k++].y = c[b];
      g[k].x = c[b];
      g[k++].y = c[a];
    }
  }
  sort(g, g + k);
  g[k].x = 0;
  g[k].y = 0;
  for (i = 0; i < k; i++) {
    j = i;
    mx = 0;
    while (g[i].x == g[i + 1].x) i++;
    for (q = j; q < i; q++)
      if (g[q].y != g[q + 1].y) mx++;
    mx++;
    if (mx > ans) {
      ans = mx;
      ansc = g[i].x;
    }
  }
  if (ansc == 0) {
    mx = 0;
    for (i = 0; i < n; i++)
      if (c[i] < c[mx]) mx = i;
    printf("%d\n", c[mx]);
  } else
    printf("%d\n", ansc);
  return 0;
}
