#define CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ordered_set tree<pair<ll,ll>, null_type, less <pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define all(name)  name.begin(),name.end()
#define rall(name)  name.rbegin(),name.rend()
#define sz(s) (int)s.size()
const int N = 2e6 + 10, mod = 1e9 + 7;
const double PI = asin(1.0) * 2;
const int OO = 0x3f3f3f3f;
int dx[]{1, -1, 0, 0, 1, 1, -1, -1};
int dy[]{0, 0, 1, -1, 1, -1, 1, -1};

void fast() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n, m, x, y;
    cin >> n >> m;
    vector<int> color(n);
    map<int, set<int>> mp;
    for (auto &i: color)
        cin >> i;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        x--, y--;
        if (color[x] != color[y])
            mp[color[x]].insert(color[y]),
                    mp[color[y]].insert(color[x]);
    }
    int mx = INT_MIN, col = -1, sz;
    for (auto i: mp) {
        sz = sz(i.second);
        if (mx < sz) {
            mx = sz;
            col = i.first;
        }
    }
    cout << col;
}

int main() {
    fast();
    //freopen("abc.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}