#include #define rep(i, n) for (int i = 0; i < (int) n; i++) using ll = long long; using namespace std; using T = tuple; using P = pair; const long long INF = 1ll << 60; template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { ll n, m, s, t; cin >> n >> m >> s >> t; s--; t--; vector p(n); rep(i, n) cin >> p[i]; vector> vertex(n); rep(i, m) { ll a, b; cin >> a >> b; a--; b--; vertex[a].push_back(b); vertex[b].push_back(a); } ll ans = 0; priority_queue pri; vector> seen(n); seen[s][0] = p[s]; pri.emplace(p[s], s, 0); while (!pri.empty()) { auto[pi, i, score] = pri.top(); pri.pop(); if (i == t) chmax(ans, score); for (auto j : vertex[i]) { if (p[j] < pi) { pri.emplace(p[j], j, score + 1); seen[j][score + 1] = p[j]; } else if (pi > seen[j][score]) { pri.emplace(pi, j, score); seen[j][score] = pi; } } } cout << ans << endl; }