/*********************************************************
*     Code written by Akikaze                            *
*     Duy-Bach Le, #Team4T's Chief Executor              *
*     #Team4T Tertiary Flagship - Oblivion               *
*                                                        *
*     Written by a random fan of momocashew and Chiho    *
*                                                        *
*     Arigatougozaimasu, imouto-chan.                    *
*********************************************************/

/***********************************************
** File name: CFR546D2D.cpp                   **
** Time created: Mon Mar 11 2019 16:30pm      **
***********************************************/

/************** [OPTIMIZATION PROTOCOL] **************/
#pragma GCC optimize("Ofast")
/*****************************************************/

/************** [LIBRARY PROTOCOL] **************/
#include <bits/stdc++.h>
using namespace std;
/************************************************/

/************** [GNU OMISSIONS] **************/
#define y0 withindarkness
#define y1 apinklotusbloomed
#define yn carryingapurplesoul
#define j1 togetherformingtheTeam
/*********************************************/

/************** [LEGENDS/CONSTANTS] **************/
#define endl '\n'
#define i64 long long
#define ld long double
#define rsz resize
#define pub push_back
#define mp make_pair
#define fi first
#define se second
typedef vector<i64> vl;
typedef vector<int> vi;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<i64, i64> pll;
typedef pair<i64, pll> plp;
typedef pair<pll, i64> ppl;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9, Gold = ((1+sqrt(5))/2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
long long keyCount = sizeof(keymod) / sizeof(long long);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
/*************************************************/

/************** [BITWISE FUNCTIONS] **************/
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcountll(s); }
/*************************************************/

/************** [MASTER CONTROLS - PHASE 1] **************/
auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();
#define OImode 227420978
#define MultiTest 227420978
#define Interactive 227420978

#undef OImode // Switch this off if submitting OI problems.
#undef MultiTest // Switch this off if submitting multi-test problems.
#undef Interactive // Switch this off if submitting interactive problems. Also required when you need to debug step-by-step.

void ControlIO(int argc, char* argv[]);
void TimerStart();
void TimerStop();
void Exit();
string cppstr_infile = "FILE.IN";
string cppstr_outfile = "FILE.OUT";
/*********************************************************/

/************** [GLOBAL VARIABLES] **************/
int n, m; vi p; vector<set<int>> adj;
/************************************************/

/************** [FUNCTIONS] **************/

void Input() {
	cin >> n >> m; p.rsz(n); adj.rsz(n);
	for (auto &z: p) {cin >> z; z--;}
	for (int i=0; i<m; i++) {
		int u, v; cin >> u >> v;
		u--; v--; adj[u].insert(v);
	}
}

void Solve() {
	int Nastya = p[n-1];
	for (int i=n-1; i>=0; i--) {
		int ptr = i;
		while (ptr+1 < n && adj[p[ptr]].find(p[ptr+1]) != adj[p[ptr]].end()) {
			swap(p[ptr], p[ptr+1]); ptr++;
		}
	}
	cout << ((n - 1) - (find(p.begin(), p.end(), Nastya) - p.begin())) << endl;
}
/*****************************************/

/************** [MAIN] **************/
int main(int argc, char* argv[]) {
	ControlIO(argc, argv);

	#ifndef Interactive
		ios_base::sync_with_stdio(0); cin.tie(NULL);
	#else
		ios_base::sync_with_stdio(0);
	#endif

	#ifndef MultiTest
		Input(); TimerStart();
		Solve(); TimerStop();
	#else
		int T; cin >> T; TimerStart();
		while(T--) {Input(); Solve();}
		TimerStop();
	#endif

	return 0;
}
/************************************/

/************** [MASTER CONTROLS - PHASE 2] **************/
void ControlIO(int argc, char* argv[]) {
	char* infile = new char[cppstr_infile.size()+1];
	char* outfile = new char[cppstr_outfile.size()+1];
	strcpy(infile, cppstr_infile.c_str());
	strcpy(outfile, cppstr_outfile.c_str());
	#ifdef Akikaze
		time_t t = time(0);
		tm* now = localtime(&t);
		cout << "Source code by #Team4T-Akikaze.\n";
		cout << "Current time: ";
		cout << (now->tm_year + 1900) << '-'
			 << ((now->tm_mon < 9) ? "0" : "") << (now->tm_mon + 1) << '-'
			 << ((now->tm_mday < 10) ? "0" : "") <<  now->tm_mday << " | "
			 << ((now->tm_hour < 10) ? "0" : "") <<  now->tm_hour << ":"
			 << ((now->tm_min < 10) ? "0" : "") <<  now->tm_min << ":"
			 << ((now->tm_sec < 10) ? "0" : "") <<  now->tm_sec
			 << "\n\n";

		#ifdef OImode
			cout << "OI-Mode: ON\n";
			cout << "Input file: " << infile << endl;
			cout << "Output file: " << outfile << endl;
			cout << "\n";
		#else
			cout << "OI-Mode: OFF\n";
			cout << "Input file: NULL\n";
			cout << "Output file: NULL\n";
			cout << "\n";
		#endif

		#ifdef MultiTest
			cout << "MultiTest-Mode: ON\n";
		#else
			cout << "MultiTest-Mode: OFF\n";
		#endif

		#ifdef Interactive
			cout << "Interactive-Mode: ON\n\n";
		#else
			cout << "Interactive-Mode: OFF\n\n";
		#endif

		if (argc > 1) assert(freopen(argv[1], "r", stdin));
		if (argc > 2) assert(freopen(argv[2], "w", stdout));
	#elif OImode
		freopen(infile, "r", stdin);
		freopen(outfile, "w", stdout);
	#endif
}

void TimerStart() {
	#ifdef Akikaze
		TimeStart = chrono::steady_clock::now();
	#endif
}

void TimerStop() {
	#ifdef Akikaze
		TimeEnd = chrono::steady_clock::now();
		auto ElapsedTime = TimeEnd - TimeStart;
		cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
	#endif
}

void Exit() {
	TimerStop(); exit(0);
}
/*********************************************************/

/*********************************************************************************************************************************************************************************************************
 * ti;.                               .:,:i:         :,;;itt;.        fDDEDDEEEEEEKEEEEEKEEEEEEEEEEEEEEEEE###WKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWW#WWWWWKKKKKEE      :,:.    f::::. .,ijLGDDDDDDDEEEEEEE*
 *ti;.                               .:,:i:          .:,;itt;:      GLDEEGEEEEEEEEEEEEEEEEEEDEEEEEEEEEEE#W#WEKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWWWWWKKKKKKG.     .::.      f:,...,ijLGDDDDDDDDEEEEEE *
 *ti;.                               .:,:i:            :,;;iti,    :fDDEEEEEEEEEEEEEEEKEEEEDEEEEEEEEEEEW##WEEEKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWWWWWWKKKKKKEG     .::.       .f,::,ijLGDDDDDDDDEEEEEE *
 *ti;.                               .:,:i:             .,,;iti;.  LDDEEEEEEEEEEKEEEEWEEEDDEEEEEEEEEEE#WWWEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWWKKKKKEDj    .::.        .:L;;ijfGDDDDDDDDDEEEEE *
 *ti;.                               .:,:i:              .:,;;iii:LLDEEEEEEEEEEEKEEEEEEEEDEEEEEEEEEEEW#WWEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKWWKWWWWWWWWWWWWWWKKKKKKKEL    .::.         .:;LijLGGDDDDDDDDEEEEE *
 *ti;.                               .:,:;:                :,;;ittfDEEEEEEEEEEEEEEEEKEEEGEEEEEEEEEEEKWWWEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWKKKKKKKELj   .::.          :,;jffGGDDDDDDDDDEEEE *
 *ti;.                               .:,:i:                 .,;;tGGDEEEEEEEEEEEKEEEKEEEDEEEEEEEEEEEEWWWEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWKWWWWWWKKKKKKKEEL   .::.          .:;itDGGDDDDDDDDDEEEE *
 *ti;.                               .:::;:                   :;ifDEEEEEEEEEEEEKEEEKEEEEEEEEEEEEEEEWWWEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#WWWKKKKKKKKEEf   .::.           :,itfGEDDDDDDDDDDDEE *
 *ti;.                               .:::;:                    :GGEEEEEEEEEEEKEKEEKEEEEEEEEEEEEEEEEWWEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#WKKKKKKKKKEEDG  .::.           .,;jfLGKDLDDDDDDEEDD *
 *ti;.                               .:::;:                     fDEEEEEEKKKKKKKKKEKEEEEEEEEEEEEEEE#WEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#KKKKKKKKKKEEf .:::.           .,;tfLGDEDDDDDDDDEEE *
 *ti;.                                :::;:                    fDEEEEEEKKKKKKKKKKWKEEEEEEEEEEEEEEEWKEEEEEEEEEEEEEEEEEEEEKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKW##KKKKKKKKKEEft :::.           .,;tfLGDDDKDDDDDDDDD *
 *ti;.                                .::;:                    fDEEEEEEKKKKKKKWKKKKKEEEEEEEEEEEEE#WEEWEEEEEDEEDEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#WKKKKKKKKEEGG :,:.           .,;tfLGGDDDKDDDDDDDD *
 *ti;.                                .:.;:                   tGDEEEEKKKKKKKKKKKKKKKKKEEEEEEEEEEEWEEKWEEEEEEEDEEEEEEEEEEEEEEKEKKKKKKKKKKKKKKKKKKKKKKKKKKWWWKKKKKKKEEDf :::.           .,;tfLGGDDDDEDDDDDDD *
 *ti;.                                .::;:                   fDEEEEEKKKKKKKKKKKWKKKKKKKKEEEEEEEWWEEWEEEEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKW##KKKKKKKEEEft.::.           .,;tfLGGDDDDDDEDDDDD *
 *ti;.                                .:.;:                  tGDEEEKKKKKKKKKKKKKKKKKKKKKKEKEEEEE#EEWWEEEEEEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKW#WKKKKKKEEEGD:::.           .,;tfLGGDDDDDDDEDDDD *
 *ti;.                                .:.,.                  LDEEEEKKKKKKKKKKWKWKKKKKKKKKKKKEEEKWEKW#EEEEEEEEEEEEEEEEKEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKW##KKKKKKEEEEf,,:.           .,;tfLGGDDDDDDDDEDDD *
 *ti;.                               ..:.,.                 LGDEEEEKKKKKKKKKKWKKKKKKKKKKKKKKKKKWEEW#WEEEEEEEEEEEEEEEKEEEEEEEEEEEEEEEEEEEKEKKKKKKKKKKKKKKKK##KKKKKEEEEEfi;,.           .,;tfLGGDDDDDDDDDKDD *
 *tt;.                                .:.,:                 jDEEEEKKKKKKKKKKWWKKKKKKKKKKKKKKKKKWKE#WWEEEEEEEEEEEEEEWEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKWWKKKKEEEEDfG;,:           .,;tfLGGDDDDDDDDDDKD *
 *tii,.                               .:.,.                tGDEEEEKKKKKKKKKKWWWKKKKKKKKKKKKKKKWKKWWWKEEEEEEEEEEEEEKEEEEEEEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKW#KKKKEEEEDGGi;,.          .,;tfLGGDDDDDDDDDDDE *
 *ti;;,:.                             .:.,:                fDEEEEKKKKKKKKKKKWKKKKKKKKKKKKKKKKKWEK#WWKEEEEEEEEEEEEDEEEEEEEEEEEEEEGEEEEEEEEEEEEEEEEEEEKKKKKKKWWKKEEEEEEDDf;;;,.         .,;tfLGGDDDDDDDDDDDD *
 *tii;,,:..                           ...,.               ;LEEEEEKKKKKKWKKKKWKKKKKKKKKKKKKKKKKEKKW#WEEEEEEEEEEEEEjEEEEEEEEEKEEEEGEEEEEEEEEKEEEEEEEEEEEEEEEEE#WKEEEEEEDDf;;;;,:        .,itfLGGDDDDDDDDDDDD *
 *ti;,,,,,:.                          ...,.               LDEEEEKKKKKKKKKKKWWWKKKKKKKKKKKKKKKWKK#W#WEEEEEEEEEEEDDLEEEEEEEEEWEEEEDEEEEEEEEEKEEEEEEEEEEEEEEEEEWWEEEEEEEDDfj,,,,,:.      .,itfGGGDDDDDDDDDDDD *
 *tii,,,,::::.                        ...,:              .fDEEEEKKKKKKWKKKKWWWKKKKKKKKKKKKKKKEKKW#WWEEEEEEEEEEEKiKEEKEEEEEEWEEEEDEEEEEEEEEEEEEEEEEEEEEEEEEEEWWEEEEEEEDDLD:::,,,:.     .,ijfGGGDDDDDDDDDDDD *
 *ti;:::::::::..                      .:.,:              LDEEEEKKKKKKKWKKKKWWKKKKKKKKKKKKKKKKtKKWWWWKEEEEEEEEEDiiDEEEEEEEEWWEEEEEEDEEEEEEEEEEEEEEEEEEEEEEEEEEWKEEEEEDDDGL:. .:,,,:    .,ijLGGGDDDDDDDDDDDD *
 *tt;. .::::::::..                    ...,:             :fDEEEKKKKKKKKKKKKWW#KKKKKKKKKKKKKKKKfKKWWWWKEEEEEEEEDti,DEKEEEEEEWWEEEDEEEEEEEEEKEEEEEEEEEEEEEDEEEEE#WEEEEEGGDGf:.  .:,;,:.  .,ijLGGDDDDDDDDDDDDD *
 *tt;.   .:::::::..                   ...,:             GDEEEKKKKKKKKWKKKKWWWKKKWKKKKKKKWWWKDEKLWWWWKKEEEEEEDEi,LDEEEEEEEEWWEEEEEEEEEEEEEEEEEEEEEEEEEDEDEEEEEW#EEEEDDDDGf,.    :,,,:...,ijLGGGDDDDDDDDDDDD *
 *tt;.    .....::::..                 ...,:             fDEEEKKKKKKKKWKKKKWWWWKKKWKKKKKKKKKKfWKiWWW#KKEEEEEEEi;.EDfEEEDEEiWWEEEEEEEEEEEEDGKEEEEEEEEEEDEEEEEEEWWEEEEDDDGGLi.     .,;,:::,ijLGGGDDDDDDDDDDDD *
 *tt;.      ....:::::.                ...,.            iDEEEEKKKKKKKKWKKWKWWWWWKKWWWKKKKKKKKtWKt#WWWKKEEEEEDji..DDKDDEDEGiWKEEEEEEEEEEDDEjEEEEEEEEEEEDEEEEEEEKWKEEDDDDGGff.      .:,;,,;ijLGGGDDDDDDDDDDDD *
 *tt;.        ....::::..              .:.,:           .LDEEEKKKKKKKKKKKKWWWWKWWWWWWWWWWKKKKWtKKiDWWWKKKEEEEKi:..DEDDDDDDiiWKEEEEEEEEEEDDEijDEEEEEKEEEEEEEEEEEEWWEEGDDDGGLG.       .:,;;iijLGGGDDDDDDDDDDDD *
 *tt;.          .....:::..            ...,.           .fEEEEKKKKKKKKWKKKKWWWWWWWWWWWWWWKWKKKiKDiLWWWWKEEEEEi,..fD:DDDDDti;WEEEEEEEEEEKDDi:iDDEEEEWEEEEEEEEEEEE#WEEGDDDDGGG.         :,iitjLGGGDDDDDDDDDDDD *
 *tti.            .....:::..          ...,.           GDEEEKKKKKKKKKWKKKWWW#WWWWWWWWWWWKWKKjiEjitWWWKKWEEEDi...DDLDDDDji;;WEEEEEEEEEEEDEj.iDDEEEEWEEEEEEEEEEEEWWEEDDDDDDGf.          .,;tjfLGGDDDDDDDDDDDD *
 *tti.              ....::::..        ...,.           fEEEKKKKKKKKKKKKKKKW#WWWWWWWWWWWWWWWWtiEiiiWWWKKEWKEi....D.EDDDEi;.fWEEEEEEEEEEDDfL.;EDDEEEWEEEEEEEEEEEEWWEEEDDDDDGf.           :;ijfLGGDDDDDDDDDDDD *
 *tti.                ....::::..      ...,.          LDEEEKKKKKKKKKKKKKKWWWWWWWWWWWWWWWW####WKiiiWWWKKKEEK,...:E:DDDEii..GWEEEEEEEEDWDDiL.,KDDEEEWEEEEEEEEEEEEWWKEEDDDDDGf:           .,itfLGGDDDDDDDDDDDD *
 *tti.                 .....:::..     ...,.          fDEEEKKKKKKKKKWKKKKWWWWWWWWWWWWW########WLiiWWWKKKEEjD...G,DDDDi;...EWEEEEEEEEDKDEii..LDDEEEWEEEEEEEEEEEEWWWEEDDDDDGfi           .,;tfLGGGDDDDDDDDDDD *
 *tti.                   .....:::..   ...,.         iGEEEKKKKKKKKKKWKKKKWWWWWWWWWWWW###########KiWWWKKEEE,.D..D.DDDii:...KKEEEEEEEEEDDj:...tEDEEEWEEEEEEEEEEEEWWWEEEDDDDDLL           .,;tjLLGGDDDDDDDDDDD *
 *tti.                     ....::::......:.         LEEEKKKKKKKKKKWWKKKWWW#KWWWWWWWW#####W####W##KWWKKEEL..:D.jjDDi;,....KKEEEEEEEDfDDi...:iKDEEEWKEEEEEEEEEEEWWWEEEEDDDDLG           .,;tjLLGGDDDDDDDDDDD *
 *tti.                        ...::::::..,.        :GEEEKKKKKKKKKKKKWWWWW##WWWWWWWWW##WKWK#W#W####WWKEEK.....G.DDti,.....KKEEEEEEDWGDf.,...iKDEEEWWEEEEEEEEEEEW#WEEEEEDDDGL           .,;tjLLGGDDDDDDDDDDD *
 *tti.                         ....::::::,.        GDEEKKKKKKKKKKKKKWWWW###WWWWWWWWWW#WWWK###W#####WKEKK.....jDDL;;......KKEEEEEEEEEDi.f...;KDEEEWWEEEEEEEEEEEWWWWEEEEEDDGf           .,;tjLLGGDDDDDDDDDDD *
 *tti.                           ....:::,,.       .LEEEKKKKKWKKKKKWWWWWW###WWWWWWWWWW#WWKW#WW##W#WWWKEKD:....:DD:;......;KEEEEEEEKiDD..f...,KKEEEWWEEEEEEEEEEEWWWWEEEEEDDDf           .:;tjLLGGGDDDDDDDDDD *
 *tti.                             ...::,,,:.     GDEEKKKKKKKKKKKKWWWWWWW#WWWWWWWWWWW#KjKWWWWWWWWWWWWEK.j,..;fD.;.......fKEEEEEDKG:Di..,....DKEEEWWEEEEEEKEKKKWWWWEEEEEEDDf           .:;tjLLGGDDDDDDDDDDD *
 *jti.                              ...::,,,,:.  .fEEEKKKKKWKKKKKKWWWWWWW#WWWWWWWWWWK#KKKWWWWWWWWWWWWWK..f:.:G.,:.......EKEEEEEKK;:E:.......fKEEEWWKEKEKKKKKKKW#WWEEEEEEDDf:          .,;tfLLGGDDDDDDDDDDD *
 *tti.                               ...:,,,;;,: iDEEKKKKKWKKKKKKKWWWWWWW#WWWWWWWWWWK#WDKWWKKWWWWWWWWWE..;G:G..,........KKEEEEEKi.Gi..:.....tKEEKWWWKKKKKKKKKKW##WKEEEEEEDfi          .,;tfLLGGGDDDDDDDDDD *
 *tti.                               ....::,,;;;,LEEKKKKKKWKKKKKWWWWWWW###WWWWWWWWWWKWWDKWEEEWKKWWWWWKKj.:LG..;.........EKEEEEKG;.G...;.....;KKEKWWWKKKKKKKKKKW##WWKEEEEEDfL          .,;tfLGGGDDDDDDDDDDD *
 *jti.                                ...::::,;ijDEEKKKKKWKKKKKKWKWWWWW##WWWWWWWWWWWKK#KKGDGDWEEWKKWKKGE,.i;.:.........:EKEEEKE;.:L...j.....,KWEKWWWKKKKKKKKKK####WKKEEEEDLG          .,;tfLGGGGDDDDDDDDDD *
 *jti.                                ...:...,,;GEEKKKKKWWKKKKKWWWWWWWW###WWWWWWWWWKKKWWKiLGGEDEDEKGKKiEG..;...........jKEEEKK;:.G....,.....:KKEWWWWKKKKKKKWKK####WKKKKEEEGL          .,;tfLGGGGDDDDDDDDDD *
 *jti.                                ...:.  .:,GEEKKKKKWKKKKKWWWWWWWW####WWWWWWWWWKKKWWKii;fDLGDK: EEi:E:.............EKEEKK;;..L...........KKKWWWWKKKKKKKWKK####WKKKWKEEDf          .,;tfGGGGDDDDDDDDDDD *
 *jti.                                ...:.    ,EEKKKKKWWKKKKKWWWWWWWWW###WWWWWWWWKKKKfWWLt;i,. fi  EG..D:.............EKEKK;;..t....:.......KWKWWWWKKKKKKKWKK####WKKKWEEEDf:.        .,;tfGGGGDDDDDDDDDDD *
 *jti.                                ...:.    GEEKKKKKWKKKKKWWWWWWWWW####WWWWWWWKKKKKt;KKEfff     .;t.................KKKKi;:..GtGGfG.......KWWWWWWKKKKKKKWKK###WWWKKKKEEEf,,:       .,;tfGGGGDDDDDDDDDDD *
 *jti.                                ...:.    GEKKKKKWWKKKKKWWWWWWWWWW##WWWWWWWKKKKKKt;EiKKKK,   ...t................jEKKG;;..,.....,LGi....KWWWWWWKKKKKKWKKKW####WKKKKKEEL,,,:.     .,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:.  .GEEKKKKKWKKKKKWWWWWWWWWW###WWWWWWWKKKKKKtiE::tGG........................EEEj;;...,.........:D..DKWWWWWWKKKKK#KKW###W#WKKKKKEEfj:,,,:.   .,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:.   DEKKKKKWWKKKKKWWWWWWWWW####WWWWWWWKKKKKKiiE:::.::.......................EEi;;...j.....f......:iDKWWWWWWKKKKK#WW######WKKKKKEELG :,,,,:. .,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:.  fEEKKKKWWKKKKWWWWWWWWWWW###WWWWWWWWKKKKKK;tE::..........................DD;.;,.::......;........EWWWWWWWKKKKW#WW#####WWKKKWKKELG  .:,,,:::,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:. .DEKEKKKWWKKKKWWWWWWWWWWW###WWWWWWWWKKKKKE,iD::..........................D..,;.,;tLffi...........DWDWWWW#KKKWWWWW#####W#KKKWKEEGL    .:,;,,,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:. ;EEKKKKWWKKKKKWWWWWW#WWWW####WWWWWWKKKKKEL:iD:..........................j ..;..;;:.....i,........DKtWWWWWKKWWWWWW#####WWWKKKEKEDf     .:,;;;itfGGGDDDDDDDDDDDD *
 *jti.                                ...:. DEKKKKKWWKKKKWWWWWWW#WWWW####WWWWWWKKKKKEj:iG...............................:....................GKiWWWWWKKWW#WWW######WWKKKKKEEf       .,;iitfGGGDDDDDDDDDDDD *
 *jti.                                ...:.:EKKKKKWWKKKKKWWWWWWW#WWW#####WWWWWKWKKKKEi:if:.................................iEKEKKKKKKDj......DKiWWWWWKWK##WW#######WWKKK:KEEL        .:;itfGGGDDDDDDDDDDDD *
 *jji.                                ...:,DEEKKKWWWKWKKWWWWWWWWWWWW#####WWWWWWWKKKKEi:it..................................j.  KKKKKKKKKKKf..DKiWWWWWKWW##WW#######WWKKK,KEEf         .,;tfGGGDDDDDDDDDDDD *
 *jji.                                ..L:iDEEKKKWWKKKKKWWWWWWWWWWWW#####WWWWWKWKKKKKi.i;..................................  . KKKWWWWWWWWK..DGiWWWWWKK##WWW#####W#WWKKKjEKEL,        .:;tfGGGDDDDDDDDDDDD *
 *jji.                               .f:::EEEKKKWWWKKKKKWWWWWWWWWWWW#####WWWWWKWKKKKK;.i,.................................::  KKEKWWWWWWfWK..EiiWWWWWKWW#WW##########KKKD,KELj        .:;tfGGDDDDDDDDDDDDD *
 *jji.                             .t::::,DEEKKKWWKKKKWWWWWWWWW#WWWW#####WWWWKKWKKKEK;.i:.................................GDDEEEKKKWWWWWtWWD.E;iWWWWWW###WW#########WWKKK.EEDG        .:;tfGGGDDDDDDDDDDDD *
 *jji.                          . j..::::EKEKKKWWWKKKKWWWWWWWWW#WWW######WWWWKKWKKKEK;.t:.................................ELLEDDEEEWWWWEtWK,.KiiWWWWWW###W##########WWKKK:EEEG     .;tjfLLGDDDDDDDDDDDDDDD *
 *jji.                          i.::::::,EEEKKWWWKKKKKWWWWWWWWW#WWW#####WWWWWKWKKKKEE,.t..................................DfiEGDDDEEKKKttKWG.KiiWWWWW##WWW##########WWKKK:fEEL  ,fGGGDDDDDDDDEEEDDDDDDDDDD *
 *jji.                        .;:..:::::DEEEKKWWWKKKKKWWWWWWWWW#WWWW####WWWWWWWKKKKED,.t..................................ifjDDGGEGDKK.ttKKE.DiWWWWW###WW##########WWWKKK:.KELiLGGGGDDDDDDDDDDDDEEEDDDDDDD *
 *jji.                       i.:.::::::,KEEKKWWWKKKKKKWWWWWWWWW#WWWW####WWWWWWWKKKKEL:.j..................................GGf,;ifLLED .iiKKi:fWWWWWW##W#W##########WWWKKK:.KKLGGDDDDDDDDDDDDDDDDEDDEEDDDDD *
 *jji.                     .j:.::::::::EEEKKKWWWKKKKKKWWWWWWWW##WWW#####WWWWWWWKKKKKf:.f..................................:EEfftf .,. ;iE,..jWWWWWWW###W############WWKKK,:KKGDDDDDDDDDDDDDDDDDDDDDDDEDDDD *
 *jji.                    .:.::::::::,,EEEKKWWWKKKKKKKWWWWWWWW##WWW#####WWWWWWWKKKKKt..G....................................EEELL;   .j....tKWWWWWWW################WWWKKtfGKGEDDDDDDDDDDDDDDDDDDDDDDDEEDD *
 *jji.                   :...:::::::,,jEEKKWWWWKKKKKKWWWWWWWWW##KWW#####KWWWWWWKKKKEi..D....................................:jEEE.........;KKWWWWWWWW#WW##W##########WWKKDLGKEKDDDDDDDDDDDDDDDDDDDDDDDDDED *
 *jji.                  i:.::::::::,,,EEEKKWWWWKKKKKWWWWWWWWWW##WWW#####WWWWWWWKKKKKi..D......................................:::::......,KKKWWWWWWWWW#####W########WWWKKKGGKKEGGGGGGGGDDDDDDDDDDDDDDDDDDE *
 *jji.                 i..:::::::::,,tEEKKWWWWKKKKKWWWWWWWWWWW##WW######WWWWWWWKKKKKi..D......................................::::......:EKKKWWWWWWWWWWW##WW########W#WKKWGGKKGGGGGGGGGGGGGGGDDDDDDDDDDDDD *
 *jji.                .:::::::::::,,,EEEKKWWWWKKKKKWWWWWWWWWWW##WW#####WWWWWWWWKKKKKi..D....................................:::::::::..tELii;KWWWWWWWWWW##WW######WWWWWWKWGGGKGGGGGGGGGGGGGGGGGGGGGGGGGGDG *
 *jjt.                :.::::::::,,,,fEEKKWWWWKKKKKKWWWWWWWWWW###WW####WWWWWWW#WKKKKKi..D....................................:::::::.:.,;;;;;;,KKWWWWWWWWW#WW########WWWKKWGGGKGGGGGGGGGGGGGGGGGGGGGGGGGGGG *
 *jji.               ;.::::::::,,,,;EEEKWWWWWKKKKKWWWWWWWWWWWW##WW###WKWWWWWK#WKKKKKi..G......................................:::::::,;;;;:...KKKWWWWWWWWWKWW#######WWWWKKGLGKDGGGGGGLLGGGGGGGGGGGGGGGGGGG *
 *jjt.              f.:::::::::,,,,fEEKKWWWWWKKKKKWWWWWWWWWWW###WW##WKKWWWWWW#WKKKKK;.jt........i.............................:::::::;j;;....:E.KKKWWWWWWWKWW#####W#WWWWKKLLGWEEGGGGGLGGGGGGGGGGGGGGGGGGGG *
 *jjt.             ...:::::::,,,,,;DEEKWWWWWKKKKKWWWWWWWWWWWW####WWWKKKWWWWWWWWKKKKK;.E;.........t.............................:::::ii;;.....D...KKWWWWWWWKWW#####WWEWWWKKGGGEKKGGGGGLGGGGGGGGGGGGGLGGGGGG *
 *fji.             ;.:::::::,,,,,;LEEKKWWWWWKKKKKWWWWWWWWWWWW####KWKKKKWWWWWWWWKKKKKi.D;..........j.............................:::tt;,.....:.....KKWWWWWWKWWWW##WWWGWWWKKGGGGKEGGGGGGGGGGGGGGGGGGGLLGGGGL *
 *fji.            t::::::::,,,,,,;EEEKWWWWWKKKKKKKWWWWWWWWWWW##WKWKKKKKWWWWWWWWKKKKKi:D;............j...........................::LL;,.............KKWWWWWKWWWWWWWWWGWWWKKGGGGKGGGGGGGGGGGGGGGGGGGGLLGGGGL *
 *fjt:            .:::::::,,,,,,,DEEKWWWWWWKKKKKKKWWWWWWWWWWWWKKWKKKKKKWWWWK#WWKKKKWitE;........... ............................:G;;:...............KKKWWKKWWWWWWWWWGWWWKKGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGL *
 *fjji;:.       .f:::::::,,,,,,,;EEEKWWWWWWKKKKKKWWWWWWWWWWWKKKKKKKKKKKWWKWWWWWKKKKWGKD;........................................L;;..................DKKWKKWWWWWWWWWGWWWKKDGGGKDGGGGGGGGGGGGGGGGGGGGGGGGGG *
 *fjjtii;,:.     :::::::,,,,,,,;EEEKWWWWWWKKKKKKWWWWWWWWWWKKKKKKKKKKKKWWWWWW#WWKKKKWiEj;......................................:i,;....,...............;KKEKWWWWWWWWWGKWWKKDDGGDEGGGDGGGGGDGGGGGGGGGGGGGGGG *
 *fjtiiiii;;:.  j::::::,,,,,,,;;EEEKWWWWW#KKKKKWWWWWWWWWKKKKKKWKKKKKKKWWWWWWWWWKKKKWtEL;:....................................;;;:...,;j................:KEEWWWWWWWWWDDWWKKDDDDDKDDDDDDDDDDDDDDDGGGGGGGGGGG *
 *fjti;;iiii;;,:::::::,,,,,,,,;EEEKWWWWWWWKKKKWWWWWWWWKKKKKKKWKKKKKKKWWWWWWW#W#KKKKWEEii;...................................f;:....,;L...................EEKWWWWWWWWDDWWKKDDDDDKEDDDDDDDDDDDDDDDDDDDDDGGGG *
 *fjt,,,;;;;ii;f::::::,,,,,,,;;EEKWWWWWWWKKKKKWWWKWWKKKKKKKKKKKKKKKKKWWWWWWW#W#KKKKWKEij;:...............................:G;,.....,;f....................:tKKWWWWWWWDDWWKKDDDDDKKDDDDDDDDDDDDDDDDDDDDDDDDD *
 *jjt. ..:,;;;;,::::,,,,,,,,;;GEEWWWWWWWWKKKKWKKWKKKKKKKKKKKKKKKKKKKKWWWWWWW#W#KKKKWEDi;j;............................,Li;L;;;..,;;f........................KKKKWWWKDDWWKKDDDGDKKGGGGGGGGDGDDDDDDDDDDDDDDD *
 *fjt.    .:,,,:::::,,,,,,,;;;EEKWWWWWWWKKKKKKWKKKKKKKKKKKKKKKKKKKKKWKKKWKW##W#KKKKWEti;;G;........................tEEEL;;;;;;;;;;L..........................DKKKKKEDDWWKEDGftiLE;;;;itjLGGGGGGDDDDDDDDDDD *
 *fjt.       .j::::,,,,,,,;;;DEEWWWWWWWWKKKKWKKKKKKKKKKKKKKKKKKKKKKKWKKWWWK##W#KKKKKEii;;;L;...................iDEEEEEEKKi;j;;;;jD.....:......................,KKKKDGGEKKE:::::;E::::::::::,tLGGDDDDDDDDDD *
 *fjt.       .;:::,,,,,,,;;;;EEKWWWWWWWWKWKKKKKKKKKKKKKKKWKKKKKKKKKKWKKWWWW#WW#KKKKKKii;;;;f;.............:tDEEEEEKKKKKKKKEti;;;L...............................EEKf;:iKKE::::::E::::::::::::::ifDDDDDDDDD *
 *fjt:        :::,,,,,,,,;;;DEEWWWWWWWWWEKKKKKKKKKKKKKKKKKKKKKKKKKKWWKKWWWW####KKKKKEiii;;;;f,.........iDEEEEKKKKKKKKKKKKKKKf;iG......i..........................fK::::KKE::::::E::::::::::::::::,tGGDDDDD *
 *fjt:       t:::,,,,,,;;;;iDEKWWWWWWKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWKKWWWW####WKKKKLiii;;;;;L,....,Li;EDEEEEKKKKKKKKKKKKKKKKiG......;:...........................:i:::KKE:::::,E,::::::::::::::::::iGDDDD *
 *jjt.       f::,,,,,,,;;;;GEEWWWWKEEKEKKKKKKKKKKKKKKKKWKKKKKKKKKKKWWKWWWWW###WWKKKKiii;;;;;;;G,;L;;iiEEEEEEEKKKKKKKKKKKKKWWKE......;t.........:....................j::KEE:,::,,D,,::::,,,,,,:::::::::tDDD *
 *fjt:.      ,::,,,,,,,;;;;EEWWKEEEEEEKKKKKKKKKKKKKKKKWKKKKKKKKKKKWWKKWWWWW#W#KKKKKKiiiiii;;;;;i;;iiiEEKEEKKWKKKKKKKWKKKKKWWWGi;...;t......,;;;;,....................:,EEE,,,,,,D,,,,,,,,,,,,,,,,::,::::tG *
 *fjt:.     ,::,,,,,,,;;;;DEKEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWW#W#KKKKKKiiiii;;i;;;;;iiiKKKEKKKKWWKWWWWWWKKKKWWWWW;;;:;L.....;;;;;;;;;....................,KEE,,,,,,E,,,,,,,,,,,,,,,,,,,,,,,,; *
 *fjt:.     f:,,,,,,,;;;;jEDEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWW#W##KKKKKKiiiiiiii;i;;iiiEKKKKKKKKWKWWWWWWWWKKKWWWWWKi;;i.....,jEEfGi;;;;;...................EED,,,,,,E,,,,,,,,,,,,,,,,,,,,,,,,, *
 *fjt:.    .f::,,,,,,;;jEEDEEEEEEEEEEKKKKKKKKKKKKKKKWKKKKKKKKKKKKKWWWKWWWWW###KKKKKLiiiiiiiiiiiiiiEEKKKKKKKKWWWWWWWWWWWWKWWWWWWGi;i;,..;jDDDKEGi;;;;;;:................EED,,,,,,D,,,,,,,,,,,,,,,,,,,,,,,,, *
 *fjt:.  .. ;::,,,,,;;EDDEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWKKW#WW####KWKKKiiiiiiiiiiiiijKKKKKKKKKKWWWWWWWWWWWWWWWWWWWWWt;i;;;;i;DDDDDDGi;;;;;;;;:.............EDf;,,,;,G;;;;;;;;;;;;;;;,,,,,,,,,, *
 *fjt:......:,,,,,,;LDDDEEEEEEEEEEEKKKKKKKKKKKKKKKKWKKKKKKKKKKKKKWWWWKWWWW####KKKKKiiiiiiiiiiijKEKKWKKKKKKKWWWWWWWWWWWWWWWWWWWWWWiLiii;i;DEEEEDDE;i;;;;;;;;;:..........EDi,;;;;;L;;;;;;;;;;;;;;;;;;,,,,,,, *
 *fjt:......:,,,,,;EDDDEEKEEEEEEEEEKKKKKKKKKKKKKKKWKKKKKKKKKKKKKKWWWWKKWWW##W#KWKKWEiiiiiijGKKKKKWWKKKKKKKKWWWWWWWWWWWWWWWWWWWWWWKi;iiiiDDEEEEEEDEi;;;;;;;;;;;;;,:.....ED;;;;;;;j;;;;;;;;;;;;;;;;;;;;;;;,, *
 *fjt:.....t,,,,,;DDDDEEEKEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWKKKWWWW##WKWKKWKiiiKKKKKKKKKWWKKKKKKKKWWWWWWWWWWWWWWW#WWWWWWWWWiiiiifLEEEEEEEEDi;i;;;;;;;;;;;;.....DD;;;;;;;i;;;;;;;;;;;;;;;;;;;;;;;;; *
 *fjt:.....G,,,,,GDDDEEEEEEEEEEEEKKKKKKKKKKKKKKKKWKKKKKKKKKKKKKKKWWWKKKWWW###WKWKKWKitKKKKKKKKKWKKKKKKKKKKWWWWWWWWWWWWWW###WWWWWWWWEiiiiiiiEEEEEEEEDGiiii;;;;;;;;;.....GD;;;;;;;i;;;;;;;;;;;;;;;;;;;;;;;;; *
 *fjt:.....L,,,,;GDDDEEEEEEEEEEKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWDGWWW###KKWWKWKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWW####WWWWWWWWWiiiiiiiiEEEEEEEEEEDi;i;;;;;;;;.....Lj;;;;;;i;iiiiii;;;;;;ii;;;;;;;;;;; *
 ***********************************************************************************************************************************************************************************************************/


/*********************************************************
*     Code written by Akikaze                            *
*     Duy-Bach Le, #Team4T's Chief Executor              *
*     #Team4T Tertiary Flagship - Oblivion               *
*                                                        *
*     Written by a random fan of momocashew and Chiho    *
*                                                        *
*     Arigatougozaimasu, imouto-chan.                    *
*********************************************************/

/***********************************************
** File name: CFR546D2D.cpp                   **
** Time created: Mon Mar 11 2019 16:30pm      **
***********************************************/

/************** [OPTIMIZATION PROTOCOL] **************/
#pragma GCC optimize("Ofast")
/*****************************************************/

/************** [LIBRARY PROTOCOL] **************/
#include <bits/stdc++.h>
using namespace std;
/************************************************/

/************** [GNU OMISSIONS] **************/
#define y0 withindarkness
#define y1 apinklotusbloomed
#define yn carryingapurplesoul
#define j1 togetherformingtheTeam
/*********************************************/

/************** [LEGENDS/CONSTANTS] **************/
#define endl '\n'
#define i64 long long
#define ld long double
#define rsz resize
#define pub push_back
#define mp make_pair
#define fi first
#define se second
typedef vector<i64> vl;
typedef vector<int> vi;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<i64, i64> pll;
typedef pair<i64, pll> plp;
typedef pair<pll, i64> ppl;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9, Gold = ((1+sqrt(5))/2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
long long keyCount = sizeof(keymod) / sizeof(long long);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
/*************************************************/

/************** [BITWISE FUNCTIONS] **************/
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcountll(s); }
/*************************************************/

/************** [MASTER CONTROLS - PHASE 1] **************/
auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();
#define OImode 227420978
#define MultiTest 227420978
#define Interactive 227420978

#undef OImode // Switch this off if submitting OI problems.
#undef MultiTest // Switch this off if submitting multi-test problems.
#undef Interactive // Switch this off if submitting interactive problems. Also required when you need to debug step-by-step.

void ControlIO(int argc, char* argv[]);
void TimerStart();
void TimerStop();
void Exit();
string cppstr_infile = "FILE.IN";
string cppstr_outfile = "FILE.OUT";
/*********************************************************/

/************** [GLOBAL VARIABLES] **************/
int n, m; vi p; vector<set<int>> adj;
/************************************************/

/************** [FUNCTIONS] **************/

void Input() {
	cin >> n >> m; p.rsz(n); adj.rsz(n);
	for (auto &z: p) {cin >> z; z--;}
	for (int i=0; i<m; i++) {
		int u, v; cin >> u >> v;
		u--; v--; adj[u].insert(v);
	}
}

void Solve() {
	int Nastya = p[n-1];
	for (int i=n-1; i>=0; i--) {
		int ptr = i;
		while (ptr+1 < n && adj[p[ptr]].find(p[ptr+1]) != adj[p[ptr]].end()) {
			swap(p[ptr], p[ptr+1]); ptr++;
		}
	}
	cout << ((n - 1) - (find(p.begin(), p.end(), Nastya) - p.begin())) << endl;
}
/*****************************************/

/************** [MAIN] **************/
int main(int argc, char* argv[]) {
	ControlIO(argc, argv);

	#ifndef Interactive
		//ios_base::sync_with_stdio(0); cin.tie(NULL);
	#else
		ios_base::sync_with_stdio(0);
	#endif

	#ifndef MultiTest
		Input(); TimerStart();
		Solve(); TimerStop();
	#else
		int T; cin >> T; TimerStart();
		while(T--) {Input(); Solve();}
		TimerStop();
	#endif

	return 0;
}
/************************************/

/************** [MASTER CONTROLS - PHASE 2] **************/
void ControlIO(int argc, char* argv[]) {
	char* infile = new char[cppstr_infile.size()+1];
	char* outfile = new char[cppstr_outfile.size()+1];
	strcpy(infile, cppstr_infile.c_str());
	strcpy(outfile, cppstr_outfile.c_str());
	#ifdef Akikaze
		time_t t = time(0);
		tm* now = localtime(&t);
		cout << "Source code by #Team4T-Akikaze.\n";
		cout << "Current time: ";
		cout << (now->tm_year + 1900) << '-'
			 << ((now->tm_mon < 9) ? "0" : "") << (now->tm_mon + 1) << '-'
			 << ((now->tm_mday < 10) ? "0" : "") <<  now->tm_mday << " | "
			 << ((now->tm_hour < 10) ? "0" : "") <<  now->tm_hour << ":"
			 << ((now->tm_min < 10) ? "0" : "") <<  now->tm_min << ":"
			 << ((now->tm_sec < 10) ? "0" : "") <<  now->tm_sec
			 << "\n\n";

		#ifdef OImode
			cout << "OI-Mode: ON\n";
			cout << "Input file: " << infile << endl;
			cout << "Output file: " << outfile << endl;
			cout << "\n";
		#else
			cout << "OI-Mode: OFF\n";
			cout << "Input file: NULL\n";
			cout << "Output file: NULL\n";
			cout << "\n";
		#endif

		#ifdef MultiTest
			cout << "MultiTest-Mode: ON\n";
		#else
			cout << "MultiTest-Mode: OFF\n";
		#endif

		#ifdef Interactive
			cout << "Interactive-Mode: ON\n\n";
		#else
			cout << "Interactive-Mode: OFF\n\n";
		#endif

		if (argc > 1) assert(freopen(argv[1], "r", stdin));
		if (argc > 2) assert(freopen(argv[2], "w", stdout));
	#elif OImode
		freopen(infile, "r", stdin);
		freopen(outfile, "w", stdout);
	#endif
}

void TimerStart() {
	#ifdef Akikaze
		TimeStart = chrono::steady_clock::now();
	#endif
}

void TimerStop() {
	#ifdef Akikaze
		TimeEnd = chrono::steady_clock::now();
		auto ElapsedTime = TimeEnd - TimeStart;
		cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
	#endif
}

void Exit() {
	TimerStop(); exit(0);
}
/*********************************************************/

/*********************************************************************************************************************************************************************************************************
 * ti;.                               .:,:i:         :,;;itt;.        fDDEDDEEEEEEKEEEEEKEEEEEEEEEEEEEEEEE###WKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWW#WWWWWKKKKKEE      :,:.    f::::. .,ijLGDDDDDDDEEEEEEE*
 *ti;.                               .:,:i:          .:,;itt;:      GLDEEGEEEEEEEEEEEEEEEEEEDEEEEEEEEEEE#W#WEKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWWWWWKKKKKKG.     .::.      f:,...,ijLGDDDDDDDDEEEEEE *
 *ti;.                               .:,:i:            :,;;iti,    :fDDEEEEEEEEEEEEEEEKEEEEDEEEEEEEEEEEW##WEEEKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWWWWWWKKKKKKEG     .::.       .f,::,ijLGDDDDDDDDEEEEEE *
 *ti;.                               .:,:i:             .,,;iti;.  LDDEEEEEEEEEEKEEEEWEEEDDEEEEEEEEEEE#WWWEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWWWWWKKKKKEDj    .::.        .:L;;ijfGDDDDDDDDDEEEEE *
 *ti;.                               .:,:i:              .:,;;iii:LLDEEEEEEEEEEEKEEEEEEEEDEEEEEEEEEEEW#WWEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKWWKWWWWWWWWWWWWWWKKKKKKKEL    .::.         .:;LijLGGDDDDDDDDEEEEE *
 *ti;.                               .:,:;:                :,;;ittfDEEEEEEEEEEEEEEEEKEEEGEEEEEEEEEEEKWWWEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWWWWKKKKKKKELj   .::.          :,;jffGGDDDDDDDDDEEEE *
 *ti;.                               .:,:i:                 .,;;tGGDEEEEEEEEEEEKEEEKEEEDEEEEEEEEEEEEWWWEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWKWWWWWWKKKKKKKEEL   .::.          .:;itDGGDDDDDDDDDEEEE *
 *ti;.                               .:::;:                   :;ifDEEEEEEEEEEEEKEEEKEEEEEEEEEEEEEEEWWWEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#WWWKKKKKKKKEEf   .::.           :,itfGEDDDDDDDDDDDEE *
 *ti;.                               .:::;:                    :GGEEEEEEEEEEEKEKEEKEEEEEEEEEEEEEEEEWWEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#WKKKKKKKKKEEDG  .::.           .,;jfLGKDLDDDDDDEEDD *
 *ti;.                               .:::;:                     fDEEEEEEKKKKKKKKKEKEEEEEEEEEEEEEEE#WEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#KKKKKKKKKKEEf .:::.           .,;tfLGDEDDDDDDDDEEE *
 *ti;.                                :::;:                    fDEEEEEEKKKKKKKKKKWKEEEEEEEEEEEEEEEWKEEEEEEEEEEEEEEEEEEEEKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKW##KKKKKKKKKEEft :::.           .,;tfLGDDDKDDDDDDDDD *
 *ti;.                                .::;:                    fDEEEEEEKKKKKKKWKKKKKEEEEEEEEEEEEE#WEEWEEEEEDEEDEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKW#WKKKKKKKKEEGG :,:.           .,;tfLGGDDDKDDDDDDDD *
 *ti;.                                .:.;:                   tGDEEEEKKKKKKKKKKKKKKKKKEEEEEEEEEEEWEEKWEEEEEEEDEEEEEEEEEEEEEEKEKKKKKKKKKKKKKKKKKKKKKKKKKKWWWKKKKKKKEEDf :::.           .,;tfLGGDDDDEDDDDDDD *
 *ti;.                                .::;:                   fDEEEEEKKKKKKKKKKKWKKKKKKKKEEEEEEEWWEEWEEEEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKW##KKKKKKKEEEft.::.           .,;tfLGGDDDDDDEDDDDD *
 *ti;.                                .:.;:                  tGDEEEKKKKKKKKKKKKKKKKKKKKKKEKEEEEE#EEWWEEEEEEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKW#WKKKKKKEEEGD:::.           .,;tfLGGDDDDDDDEDDDD *
 *ti;.                                .:.,.                  LDEEEEKKKKKKKKKKWKWKKKKKKKKKKKKEEEKWEKW#EEEEEEEEEEEEEEEEKEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKW##KKKKKKEEEEf,,:.           .,;tfLGGDDDDDDDDEDDD *
 *ti;.                               ..:.,.                 LGDEEEEKKKKKKKKKKWKKKKKKKKKKKKKKKKKWEEW#WEEEEEEEEEEEEEEEKEEEEEEEEEEEEEEEEEEEKEKKKKKKKKKKKKKKKK##KKKKKEEEEEfi;,.           .,;tfLGGDDDDDDDDDKDD *
 *tt;.                                .:.,:                 jDEEEEKKKKKKKKKKWWKKKKKKKKKKKKKKKKKWKE#WWEEEEEEEEEEEEEEWEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKKKKKKWWKKKKEEEEDfG;,:           .,;tfLGGDDDDDDDDDDKD *
 *tii,.                               .:.,.                tGDEEEEKKKKKKKKKKWWWKKKKKKKKKKKKKKKWKKWWWKEEEEEEEEEEEEEKEEEEEEEEEEEEEEEEEEEEEEEEEEEEEKKKKKKKKKKKW#KKKKEEEEDGGi;,.          .,;tfLGGDDDDDDDDDDDE *
 *ti;;,:.                             .:.,:                fDEEEEKKKKKKKKKKKWKKKKKKKKKKKKKKKKKWEK#WWKEEEEEEEEEEEEDEEEEEEEEEEEEEEGEEEEEEEEEEEEEEEEEEEKKKKKKKWWKKEEEEEEDDf;;;,.         .,;tfLGGDDDDDDDDDDDD *
 *tii;,,:..                           ...,.               ;LEEEEEKKKKKKWKKKKWKKKKKKKKKKKKKKKKKEKKW#WEEEEEEEEEEEEEjEEEEEEEEEKEEEEGEEEEEEEEEKEEEEEEEEEEEEEEEEE#WKEEEEEEDDf;;;;,:        .,itfLGGDDDDDDDDDDDD *
 *ti;,,,,,:.                          ...,.               LDEEEEKKKKKKKKKKKWWWKKKKKKKKKKKKKKKWKK#W#WEEEEEEEEEEEDDLEEEEEEEEEWEEEEDEEEEEEEEEKEEEEEEEEEEEEEEEEEWWEEEEEEEDDfj,,,,,:.      .,itfGGGDDDDDDDDDDDD *
 *tii,,,,::::.                        ...,:              .fDEEEEKKKKKKWKKKKWWWKKKKKKKKKKKKKKKEKKW#WWEEEEEEEEEEEKiKEEKEEEEEEWEEEEDEEEEEEEEEEEEEEEEEEEEEEEEEEEWWEEEEEEEDDLD:::,,,:.     .,ijfGGGDDDDDDDDDDDD *
 *ti;:::::::::..                      .:.,:              LDEEEEKKKKKKKWKKKKWWKKKKKKKKKKKKKKKKtKKWWWWKEEEEEEEEEDiiDEEEEEEEEWWEEEEEEDEEEEEEEEEEEEEEEEEEEEEEEEEEWKEEEEEDDDGL:. .:,,,:    .,ijLGGGDDDDDDDDDDDD *
 *tt;. .::::::::..                    ...,:             :fDEEEKKKKKKKKKKKKWW#KKKKKKKKKKKKKKKKfKKWWWWKEEEEEEEEDti,DEKEEEEEEWWEEEDEEEEEEEEEKEEEEEEEEEEEEEDEEEEE#WEEEEEGGDGf:.  .:,;,:.  .,ijLGGDDDDDDDDDDDDD *
 *tt;.   .:::::::..                   ...,:             GDEEEKKKKKKKKWKKKKWWWKKKWKKKKKKKWWWKDEKLWWWWKKEEEEEEDEi,LDEEEEEEEEWWEEEEEEEEEEEEEEEEEEEEEEEEEDEDEEEEEW#EEEEDDDDGf,.    :,,,:...,ijLGGGDDDDDDDDDDDD *
 *tt;.    .....::::..                 ...,:             fDEEEKKKKKKKKWKKKKWWWWKKKWKKKKKKKKKKfWKiWWW#KKEEEEEEEi;.EDfEEEDEEiWWEEEEEEEEEEEEDGKEEEEEEEEEEDEEEEEEEWWEEEEDDDGGLi.     .,;,:::,ijLGGGDDDDDDDDDDDD *
 *tt;.      ....:::::.                ...,.            iDEEEEKKKKKKKKWKKWKWWWWWKKWWWKKKKKKKKtWKt#WWWKKEEEEEDji..DDKDDEDEGiWKEEEEEEEEEEDDEjEEEEEEEEEEEDEEEEEEEKWKEEDDDDGGff.      .:,;,,;ijLGGGDDDDDDDDDDDD *
 *tt;.        ....::::..              .:.,:           .LDEEEKKKKKKKKKKKKWWWWKWWWWWWWWWWKKKKWtKKiDWWWKKKEEEEKi:..DEDDDDDDiiWKEEEEEEEEEEDDEijDEEEEEKEEEEEEEEEEEEWWEEGDDDGGLG.       .:,;;iijLGGGDDDDDDDDDDDD *
 *tt;.          .....:::..            ...,.           .fEEEEKKKKKKKKWKKKKWWWWWWWWWWWWWWKWKKKiKDiLWWWWKEEEEEi,..fD:DDDDDti;WEEEEEEEEEEKDDi:iDDEEEEWEEEEEEEEEEEE#WEEGDDDDGGG.         :,iitjLGGGDDDDDDDDDDDD *
 *tti.            .....:::..          ...,.           GDEEEKKKKKKKKKWKKKWWW#WWWWWWWWWWWKWKKjiEjitWWWKKWEEEDi...DDLDDDDji;;WEEEEEEEEEEEDEj.iDDEEEEWEEEEEEEEEEEEWWEEDDDDDDGf.          .,;tjfLGGDDDDDDDDDDDD *
 *tti.              ....::::..        ...,.           fEEEKKKKKKKKKKKKKKKW#WWWWWWWWWWWWWWWWtiEiiiWWWKKEWKEi....D.EDDDEi;.fWEEEEEEEEEEDDfL.;EDDEEEWEEEEEEEEEEEEWWEEEDDDDDGf.           :;ijfLGGDDDDDDDDDDDD *
 *tti.                ....::::..      ...,.          LDEEEKKKKKKKKKKKKKKWWWWWWWWWWWWWWWW####WKiiiWWWKKKEEK,...:E:DDDEii..GWEEEEEEEEDWDDiL.,KDDEEEWEEEEEEEEEEEEWWKEEDDDDDGf:           .,itfLGGDDDDDDDDDDDD *
 *tti.                 .....:::..     ...,.          fDEEEKKKKKKKKKWKKKKWWWWWWWWWWWWW########WLiiWWWKKKEEjD...G,DDDDi;...EWEEEEEEEEDKDEii..LDDEEEWEEEEEEEEEEEEWWWEEDDDDDGfi           .,;tfLGGGDDDDDDDDDDD *
 *tti.                   .....:::..   ...,.         iGEEEKKKKKKKKKKWKKKKWWWWWWWWWWWW###########KiWWWKKEEE,.D..D.DDDii:...KKEEEEEEEEEDDj:...tEDEEEWEEEEEEEEEEEEWWWEEEDDDDDLL           .,;tjLLGGDDDDDDDDDDD *
 *tti.                     ....::::......:.         LEEEKKKKKKKKKKWWKKKWWW#KWWWWWWWW#####W####W##KWWKKEEL..:D.jjDDi;,....KKEEEEEEEDfDDi...:iKDEEEWKEEEEEEEEEEEWWWEEEEDDDDLG           .,;tjLLGGDDDDDDDDDDD *
 *tti.                        ...::::::..,.        :GEEEKKKKKKKKKKKKWWWWW##WWWWWWWWW##WKWK#W#W####WWKEEK.....G.DDti,.....KKEEEEEEDWGDf.,...iKDEEEWWEEEEEEEEEEEW#WEEEEEDDDGL           .,;tjLLGGDDDDDDDDDDD *
 *tti.                         ....::::::,.        GDEEKKKKKKKKKKKKKWWWW###WWWWWWWWWW#WWWK###W#####WKEKK.....jDDL;;......KKEEEEEEEEEDi.f...;KDEEEWWEEEEEEEEEEEWWWWEEEEEDDGf           .,;tjLLGGDDDDDDDDDDD *
 *tti.                           ....:::,,.       .LEEEKKKKKWKKKKKWWWWWW###WWWWWWWWWW#WWKW#WW##W#WWWKEKD:....:DD:;......;KEEEEEEEKiDD..f...,KKEEEWWEEEEEEEEEEEWWWWEEEEEDDDf           .:;tjLLGGGDDDDDDDDDD *
 *tti.                             ...::,,,:.     GDEEKKKKKKKKKKKKWWWWWWW#WWWWWWWWWWW#KjKWWWWWWWWWWWWEK.j,..;fD.;.......fKEEEEEDKG:Di..,....DKEEEWWEEEEEEKEKKKWWWWEEEEEEDDf           .:;tjLLGGDDDDDDDDDDD *
 *jti.                              ...::,,,,:.  .fEEEKKKKKWKKKKKKWWWWWWW#WWWWWWWWWWK#KKKWWWWWWWWWWWWWK..f:.:G.,:.......EKEEEEEKK;:E:.......fKEEEWWKEKEKKKKKKKW#WWEEEEEEDDf:          .,;tfLLGGDDDDDDDDDDD *
 *tti.                               ...:,,,;;,: iDEEKKKKKWKKKKKKKWWWWWWW#WWWWWWWWWWK#WDKWWKKWWWWWWWWWE..;G:G..,........KKEEEEEKi.Gi..:.....tKEEKWWWKKKKKKKKKKW##WKEEEEEEDfi          .,;tfLLGGGDDDDDDDDDD *
 *tti.                               ....::,,;;;,LEEKKKKKKWKKKKKWWWWWWW###WWWWWWWWWWKWWDKWEEEWKKWWWWWKKj.:LG..;.........EKEEEEKG;.G...;.....;KKEKWWWKKKKKKKKKKW##WWKEEEEEDfL          .,;tfLGGGDDDDDDDDDDD *
 *jti.                                ...::::,;ijDEEKKKKKWKKKKKKWKWWWWW##WWWWWWWWWWWKK#KKGDGDWEEWKKWKKGE,.i;.:.........:EKEEEKE;.:L...j.....,KWEKWWWKKKKKKKKKK####WKKEEEEDLG          .,;tfLGGGGDDDDDDDDDD *
 *jti.                                ...:...,,;GEEKKKKKWWKKKKKWWWWWWWW###WWWWWWWWWKKKWWKiLGGEDEDEKGKKiEG..;...........jKEEEKK;:.G....,.....:KKEWWWWKKKKKKKWKK####WKKKKEEEGL          .,;tfLGGGGDDDDDDDDDD *
 *jti.                                ...:.  .:,GEEKKKKKWKKKKKWWWWWWWW####WWWWWWWWWKKKWWKii;fDLGDK: EEi:E:.............EKEEKK;;..L...........KKKWWWWKKKKKKKWKK####WKKKWKEEDf          .,;tfGGGGDDDDDDDDDDD *
 *jti.                                ...:.    ,EEKKKKKWWKKKKKWWWWWWWWW###WWWWWWWWKKKKfWWLt;i,. fi  EG..D:.............EKEKK;;..t....:.......KWKWWWWKKKKKKKWKK####WKKKWEEEDf:.        .,;tfGGGGDDDDDDDDDDD *
 *jti.                                ...:.    GEEKKKKKWKKKKKWWWWWWWWW####WWWWWWWKKKKKt;KKEfff     .;t.................KKKKi;:..GtGGfG.......KWWWWWWKKKKKKKWKK###WWWKKKKEEEf,,:       .,;tfGGGGDDDDDDDDDDD *
 *jti.                                ...:.    GEKKKKKWWKKKKKWWWWWWWWWW##WWWWWWWKKKKKKt;EiKKKK,   ...t................jEKKG;;..,.....,LGi....KWWWWWWKKKKKKWKKKW####WKKKKKEEL,,,:.     .,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:.  .GEEKKKKKWKKKKKWWWWWWWWWW###WWWWWWWKKKKKKtiE::tGG........................EEEj;;...,.........:D..DKWWWWWWKKKKK#KKW###W#WKKKKKEEfj:,,,:.   .,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:.   DEKKKKKWWKKKKKWWWWWWWWW####WWWWWWWKKKKKKiiE:::.::.......................EEi;;...j.....f......:iDKWWWWWWKKKKK#WW######WKKKKKEELG :,,,,:. .,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:.  fEEKKKKWWKKKKWWWWWWWWWWW###WWWWWWWWKKKKKK;tE::..........................DD;.;,.::......;........EWWWWWWWKKKKW#WW#####WWKKKWKKELG  .:,,,:::,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:. .DEKEKKKWWKKKKWWWWWWWWWWW###WWWWWWWWKKKKKE,iD::..........................D..,;.,;tLffi...........DWDWWWW#KKKWWWWW#####W#KKKWKEEGL    .:,;,,,;tfGGGDDDDDDDDDDDD *
 *jti.                                ...:. ;EEKKKKWWKKKKKWWWWWW#WWWW####WWWWWWKKKKKEL:iD:..........................j ..;..;;:.....i,........DKtWWWWWKKWWWWWW#####WWWKKKEKEDf     .:,;;;itfGGGDDDDDDDDDDDD *
 *jti.                                ...:. DEKKKKKWWKKKKWWWWWWW#WWWW####WWWWWWKKKKKEj:iG...............................:....................GKiWWWWWKKWW#WWW######WWKKKKKEEf       .,;iitfGGGDDDDDDDDDDDD *
 *jti.                                ...:.:EKKKKKWWKKKKKWWWWWWW#WWW#####WWWWWKWKKKKEi:if:.................................iEKEKKKKKKDj......DKiWWWWWKWK##WW#######WWKKK:KEEL        .:;itfGGGDDDDDDDDDDDD *
 *jji.                                ...:,DEEKKKWWWKWKKWWWWWWWWWWWW#####WWWWWWWKKKKEi:it..................................j.  KKKKKKKKKKKf..DKiWWWWWKWW##WW#######WWKKK,KEEf         .,;tfGGGDDDDDDDDDDDD *
 *jji.                                ..L:iDEEKKKWWKKKKKWWWWWWWWWWWW#####WWWWWKWKKKKKi.i;..................................  . KKKWWWWWWWWK..DGiWWWWWKK##WWW#####W#WWKKKjEKEL,        .:;tfGGGDDDDDDDDDDDD *
 *jji.                               .f:::EEEKKKWWWKKKKKWWWWWWWWWWWW#####WWWWWKWKKKKK;.i,.................................::  KKEKWWWWWWfWK..EiiWWWWWKWW#WW##########KKKD,KELj        .:;tfGGDDDDDDDDDDDDD *
 *jji.                             .t::::,DEEKKKWWKKKKWWWWWWWWW#WWWW#####WWWWKKWKKKEK;.i:.................................GDDEEEKKKWWWWWtWWD.E;iWWWWWW###WW#########WWKKK.EEDG        .:;tfGGGDDDDDDDDDDDD *
 *jji.                          . j..::::EKEKKKWWWKKKKWWWWWWWWW#WWW######WWWWKKWKKKEK;.t:.................................ELLEDDEEEWWWWEtWK,.KiiWWWWWW###W##########WWKKK:EEEG     .;tjfLLGDDDDDDDDDDDDDDD *
 *jji.                          i.::::::,EEEKKWWWKKKKKWWWWWWWWW#WWW#####WWWWWKWKKKKEE,.t..................................DfiEGDDDEEKKKttKWG.KiiWWWWW##WWW##########WWKKK:fEEL  ,fGGGDDDDDDDDEEEDDDDDDDDDD *
 *jji.                        .;:..:::::DEEEKKWWWKKKKKWWWWWWWWW#WWWW####WWWWWWWKKKKED,.t..................................ifjDDGGEGDKK.ttKKE.DiWWWWW###WW##########WWWKKK:.KELiLGGGGDDDDDDDDDDDDEEEDDDDDDD *
 *jji.                       i.:.::::::,KEEKKWWWKKKKKKWWWWWWWWW#WWWW####WWWWWWWKKKKEL:.j..................................GGf,;ifLLED .iiKKi:fWWWWWW##W#W##########WWWKKK:.KKLGGDDDDDDDDDDDDDDDDEDDEEDDDDD *
 *jji.                     .j:.::::::::EEEKKKWWWKKKKKKWWWWWWWW##WWW#####WWWWWWWKKKKKf:.f..................................:EEfftf .,. ;iE,..jWWWWWWW###W############WWKKK,:KKGDDDDDDDDDDDDDDDDDDDDDDDEDDDD *
 *jji.                    .:.::::::::,,EEEKKWWWKKKKKKKWWWWWWWW##WWW#####WWWWWWWKKKKKt..G....................................EEELL;   .j....tKWWWWWWW################WWWKKtfGKGEDDDDDDDDDDDDDDDDDDDDDDDEEDD *
 *jji.                   :...:::::::,,jEEKKWWWWKKKKKKWWWWWWWWW##KWW#####KWWWWWWKKKKEi..D....................................:jEEE.........;KKWWWWWWWW#WW##W##########WWKKDLGKEKDDDDDDDDDDDDDDDDDDDDDDDDDED *
 *jji.                  i:.::::::::,,,EEEKKWWWWKKKKKWWWWWWWWWW##WWW#####WWWWWWWKKKKKi..D......................................:::::......,KKKWWWWWWWWW#####W########WWWKKKGGKKEGGGGGGGGDDDDDDDDDDDDDDDDDDE *
 *jji.                 i..:::::::::,,tEEKKWWWWKKKKKWWWWWWWWWWW##WW######WWWWWWWKKKKKi..D......................................::::......:EKKKWWWWWWWWWWW##WW########W#WKKWGGKKGGGGGGGGGGGGGGGDDDDDDDDDDDDD *
 *jji.                .:::::::::::,,,EEEKKWWWWKKKKKWWWWWWWWWWW##WW#####WWWWWWWWKKKKKi..D....................................:::::::::..tELii;KWWWWWWWWWW##WW######WWWWWWKWGGGKGGGGGGGGGGGGGGGGGGGGGGGGGGDG *
 *jjt.                :.::::::::,,,,fEEKKWWWWKKKKKKWWWWWWWWWW###WW####WWWWWWW#WKKKKKi..D....................................:::::::.:.,;;;;;;,KKWWWWWWWWW#WW########WWWKKWGGGKGGGGGGGGGGGGGGGGGGGGGGGGGGGG *
 *jji.               ;.::::::::,,,,;EEEKWWWWWKKKKKWWWWWWWWWWWW##WW###WKWWWWWK#WKKKKKi..G......................................:::::::,;;;;:...KKKWWWWWWWWWKWW#######WWWWKKGLGKDGGGGGGLLGGGGGGGGGGGGGGGGGGG *
 *jjt.              f.:::::::::,,,,fEEKKWWWWWKKKKKWWWWWWWWWWW###WW##WKKWWWWWW#WKKKKK;.jt........i.............................:::::::;j;;....:E.KKKWWWWWWWKWW#####W#WWWWKKLLGWEEGGGGGLGGGGGGGGGGGGGGGGGGGG *
 *jjt.             ...:::::::,,,,,;DEEKWWWWWKKKKKWWWWWWWWWWWW####WWWKKKWWWWWWWWKKKKK;.E;.........t.............................:::::ii;;.....D...KKWWWWWWWKWW#####WWEWWWKKGGGEKKGGGGGLGGGGGGGGGGGGGLGGGGGG *
 *fji.             ;.:::::::,,,,,;LEEKKWWWWWKKKKKWWWWWWWWWWWW####KWKKKKWWWWWWWWKKKKKi.D;..........j.............................:::tt;,.....:.....KKWWWWWWKWWWW##WWWGWWWKKGGGGKEGGGGGGGGGGGGGGGGGGGLLGGGGL *
 *fji.            t::::::::,,,,,,;EEEKWWWWWKKKKKKKWWWWWWWWWWW##WKWKKKKKWWWWWWWWKKKKKi:D;............j...........................::LL;,.............KKWWWWWKWWWWWWWWWGWWWKKGGGGKGGGGGGGGGGGGGGGGGGGGLLGGGGL *
 *fjt:            .:::::::,,,,,,,DEEKWWWWWWKKKKKKKWWWWWWWWWWWWKKWKKKKKKWWWWK#WWKKKKWitE;........... ............................:G;;:...............KKKWWKKWWWWWWWWWGWWWKKGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGL *
 *fjji;:.       .f:::::::,,,,,,,;EEEKWWWWWWKKKKKKWWWWWWWWWWWKKKKKKKKKKKWWKWWWWWKKKKWGKD;........................................L;;..................DKKWKKWWWWWWWWWGWWWKKDGGGKDGGGGGGGGGGGGGGGGGGGGGGGGGG *
 *fjjtii;,:.     :::::::,,,,,,,;EEEKWWWWWWKKKKKKWWWWWWWWWWKKKKKKKKKKKKWWWWWW#WWKKKKWiEj;......................................:i,;....,...............;KKEKWWWWWWWWWGKWWKKDDGGDEGGGDGGGGGDGGGGGGGGGGGGGGGG *
 *fjtiiiii;;:.  j::::::,,,,,,,;;EEEKWWWWW#KKKKKWWWWWWWWWKKKKKKWKKKKKKKWWWWWWWWWKKKKWtEL;:....................................;;;:...,;j................:KEEWWWWWWWWWDDWWKKDDDDDKDDDDDDDDDDDDDDDGGGGGGGGGGG *
 *fjti;;iiii;;,:::::::,,,,,,,,;EEEKWWWWWWWKKKKWWWWWWWWKKKKKKKWKKKKKKKWWWWWWW#W#KKKKWEEii;...................................f;:....,;L...................EEKWWWWWWWWDDWWKKDDDDDKEDDDDDDDDDDDDDDDDDDDDDGGGG *
 *fjt,,,;;;;ii;f::::::,,,,,,,;;EEKWWWWWWWKKKKKWWWKWWKKKKKKKKKKKKKKKKKWWWWWWW#W#KKKKWKEij;:...............................:G;,.....,;f....................:tKKWWWWWWWDDWWKKDDDDDKKDDDDDDDDDDDDDDDDDDDDDDDDD *
 *jjt. ..:,;;;;,::::,,,,,,,,;;GEEWWWWWWWWKKKKWKKWKKKKKKKKKKKKKKKKKKKKWWWWWWW#W#KKKKWEDi;j;............................,Li;L;;;..,;;f........................KKKKWWWKDDWWKKDDDGDKKGGGGGGGGDGDDDDDDDDDDDDDDD *
 *fjt.    .:,,,:::::,,,,,,,;;;EEKWWWWWWWKKKKKKWKKKKKKKKKKKKKKKKKKKKKWKKKWKW##W#KKKKWEti;;G;........................tEEEL;;;;;;;;;;L..........................DKKKKKEDDWWKEDGftiLE;;;;itjLGGGGGGDDDDDDDDDDD *
 *fjt.       .j::::,,,,,,,;;;DEEWWWWWWWWKKKKWKKKKKKKKKKKKKKKKKKKKKKKWKKWWWK##W#KKKKKEii;;;L;...................iDEEEEEEKKi;j;;;;jD.....:......................,KKKKDGGEKKE:::::;E::::::::::,tLGGDDDDDDDDDD *
 *fjt.       .;:::,,,,,,,;;;;EEKWWWWWWWWKWKKKKKKKKKKKKKKKWKKKKKKKKKKWKKWWWW#WW#KKKKKKii;;;;f;.............:tDEEEEEKKKKKKKKEti;;;L...............................EEKf;:iKKE::::::E::::::::::::::ifDDDDDDDDD *
 *fjt:        :::,,,,,,,,;;;DEEWWWWWWWWWEKKKKKKKKKKKKKKKKKKKKKKKKKKWWKKWWWW####KKKKKEiii;;;;f,.........iDEEEEKKKKKKKKKKKKKKKf;iG......i..........................fK::::KKE::::::E::::::::::::::::,tGGDDDDD *
 *fjt:       t:::,,,,,,;;;;iDEKWWWWWWKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWKKWWWW####WKKKKLiii;;;;;L,....,Li;EDEEEEKKKKKKKKKKKKKKKKiG......;:...........................:i:::KKE:::::,E,::::::::::::::::::iGDDDD *
 *jjt.       f::,,,,,,,;;;;GEEWWWWKEEKEKKKKKKKKKKKKKKKKWKKKKKKKKKKKWWKWWWWW###WWKKKKiii;;;;;;;G,;L;;iiEEEEEEEKKKKKKKKKKKKKWWKE......;t.........:....................j::KEE:,::,,D,,::::,,,,,,:::::::::tDDD *
 *fjt:.      ,::,,,,,,,;;;;EEWWKEEEEEEKKKKKKKKKKKKKKKKWKKKKKKKKKKKWWKKWWWWW#W#KKKKKKiiiiii;;;;;i;;iiiEEKEEKKWKKKKKKKWKKKKKWWWGi;...;t......,;;;;,....................:,EEE,,,,,,D,,,,,,,,,,,,,,,,::,::::tG *
 *fjt:.     ,::,,,,,,,;;;;DEKEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWW#W#KKKKKKiiiii;;i;;;;;iiiKKKEKKKKWWKWWWWWWKKKKWWWWW;;;:;L.....;;;;;;;;;....................,KEE,,,,,,E,,,,,,,,,,,,,,,,,,,,,,,,; *
 *fjt:.     f:,,,,,,,;;;;jEDEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWW#W##KKKKKKiiiiiiii;i;;iiiEKKKKKKKKWKWWWWWWWWKKKWWWWWKi;;i.....,jEEfGi;;;;;...................EED,,,,,,E,,,,,,,,,,,,,,,,,,,,,,,,, *
 *fjt:.    .f::,,,,,,;;jEEDEEEEEEEEEEKKKKKKKKKKKKKKKWKKKKKKKKKKKKKWWWKWWWWW###KKKKKLiiiiiiiiiiiiiiEEKKKKKKKKWWWWWWWWWWWWKWWWWWWGi;i;,..;jDDDKEGi;;;;;;:................EED,,,,,,D,,,,,,,,,,,,,,,,,,,,,,,,, *
 *fjt:.  .. ;::,,,,,;;EDDEEEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWKKW#WW####KWKKKiiiiiiiiiiiiijKKKKKKKKKKWWWWWWWWWWWWWWWWWWWWWt;i;;;;i;DDDDDDGi;;;;;;;;:.............EDf;,,,;,G;;;;;;;;;;;;;;;,,,,,,,,,, *
 *fjt:......:,,,,,,;LDDDEEEEEEEEEEEKKKKKKKKKKKKKKKKWKKKKKKKKKKKKKWWWWKWWWW####KKKKKiiiiiiiiiiijKEKKWKKKKKKKWWWWWWWWWWWWWWWWWWWWWWiLiii;i;DEEEEDDE;i;;;;;;;;;:..........EDi,;;;;;L;;;;;;;;;;;;;;;;;;,,,,,,, *
 *fjt:......:,,,,,;EDDDEEKEEEEEEEEEKKKKKKKKKKKKKKKWKKKKKKKKKKKKKKWWWWKKWWW##W#KWKKWEiiiiiijGKKKKKWWKKKKKKKKWWWWWWWWWWWWWWWWWWWWWWKi;iiiiDDEEEEEEDEi;;;;;;;;;;;;;,:.....ED;;;;;;;j;;;;;;;;;;;;;;;;;;;;;;;,, *
 *fjt:.....t,,,,,;DDDDEEEKEEEEEEEEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWKKKWWWW##WKWKKWKiiiKKKKKKKKKWWKKKKKKKKWWWWWWWWWWWWWWW#WWWWWWWWWiiiiifLEEEEEEEEDi;i;;;;;;;;;;;;.....DD;;;;;;;i;;;;;;;;;;;;;;;;;;;;;;;;; *
 *fjt:.....G,,,,,GDDDEEEEEEEEEEEEKKKKKKKKKKKKKKKKWKKKKKKKKKKKKKKKWWWKKKWWW###WKWKKWKitKKKKKKKKKWKKKKKKKKKKWWWWWWWWWWWWWW###WWWWWWWWEiiiiiiiEEEEEEEEDGiiii;;;;;;;;;.....GD;;;;;;;i;;;;;;;;;;;;;;;;;;;;;;;;; *
 *fjt:.....L,,,,;GDDDEEEEEEEEEEKEKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKWWWWWDGWWW###KKWWKWKKKKKKKKKKKKKKKKKKKKKKKWWWWWWWWWWWWW####WWWWWWWWWiiiiiiiiEEEEEEEEEEDi;i;;;;;;;;.....Lj;;;;;;i;iiiiii;;;;;;ii;;;;;;;;;;; *
 ***********************************************************************************************************************************************************************************************************/


#include<bits/stdc++.h>
using namespace std;

#define fou(i,a,b) for(int i = a, _i = b; i <= _i; ++i)
#define fod(i,a,b) for(int i = a, _i = b; i >= _i; --i)
template<typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T (&t)){ return t.size(); } string to_string(char b){ return "'" + string({b}) + "'"; } string to_string(bool b){ return (b ? "true" : "false"); } string to_string(const string &t, int x1=0, int x2=1e9){ string ret = ""; fou(i,min(x1,SIZE(t)),min(x2,SIZE(t)-1)){ ret += t[i]; } return '"' + ret + '"'; } string to_string(const char* t){ string ret(t); return to_string(ret); } template<size_t N> string to_string(const bitset<N> &t, int x1=0, int x2=1e9){ string ret = ""; fou(i,min(x1,SIZE(t)),min(x2,SIZE(t)-1)){ ret += t[i] + '0'; } return '"' + ret + '"'; } template<typename T, typename... Coords> string to_string(const T (&t), int x1=0, int x2=1e9, Coords... C); template<typename T, typename S> string to_string(const pair<T, S> (&t)){ return "(" + to_string(t.first) + ", " + to_string(t.second) + ")"; } template<typename T, typename... Coords> string to_string(const T (&t), int x1, int x2, Coords... C){ string ret = "["; x1 = min(x1, SIZE(t)); auto e = begin(t); advance(e, x1); fou(i,x1,min(x2,SIZE(t)-1)){ ret += (i != x1 ? ", " : "") + to_string(*e, C...); e = next(e); } return ret + "]"; } void dbgm(){;} template<typename T, typename... S> void dbgm(T t, S... s){ cout << to_string(t) << " | "; dbgm(s...); } void dbgs(){;} template<typename T, typename... S> void dbgs(T t, S... s){ cout << t << " "; dbgs(s...);}
#define dbgr(...) cout << to_string(__VA_ARGS__) << endl;
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl;

#define ll long long
#define eb emplace_back

const ll N = 2e5+3, M = 1e9+7;
int let[N], a[N], pos[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;

    fou(i,1,n){
        cin >> a[i];
        pos[a[i]] = i;
    }

    int start = a[n];

    set<pair<int, int>> g;
    int pt = 0;
    fou(i,1,m){
        int u,v; cin >> u >> v;
        g.insert({u,v});
        if(v == a[n]){
            let[++pt] = u;
        }
    }

    m = pt;
    sort(let+1, let+1+m, greater<int>());
    // dbg(let,1,m);

    fou(i,1,m){
        fou(j,pos[let[i]],n-1){
            if(g.count(pair<int, int>{a[j], a[j+1]})){
                pos[a[j]]++;
                pos[a[j+1]]--;
                swap(a[j], a[j+1]);
            }
        }
    }
    // dbg(a,1,n);

    dbgs(n-pos[start]);
}


#include<bits/stdc++.h>
using namespace std;

#define fou(i,a,b) for(int i = a, _i = b; i <= _i; ++i)
#define fod(i,a,b) for(int i = a, _i = b; i >= _i; --i)
template<typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T (&t)){ return t.size(); } string to_string(char b){ return "'" + string({b}) + "'"; } string to_string(bool b){ return (b ? "true" : "false"); } string to_string(const string &t, int x1=0, int x2=1e9){ string ret = ""; fou(i,min(x1,SIZE(t)),min(x2,SIZE(t)-1)){ ret += t[i]; } return '"' + ret + '"'; } string to_string(const char* t){ string ret(t); return to_string(ret); } template<size_t N> string to_string(const bitset<N> &t, int x1=0, int x2=1e9){ string ret = ""; fou(i,min(x1,SIZE(t)),min(x2,SIZE(t)-1)){ ret += t[i] + '0'; } return '"' + ret + '"'; } template<typename T, typename... Coords> string to_string(const T (&t), int x1=0, int x2=1e9, Coords... C); template<typename T, typename S> string to_string(const pair<T, S> (&t)){ return "(" + to_string(t.first) + ", " + to_string(t.second) + ")"; } template<typename T, typename... Coords> string to_string(const T (&t), int x1, int x2, Coords... C){ string ret = "["; x1 = min(x1, SIZE(t)); auto e = begin(t); advance(e, x1); fou(i,x1,min(x2,SIZE(t)-1)){ ret += (i != x1 ? ", " : "") + to_string(*e, C...); e = next(e); } return ret + "]"; } void dbgm(){;} template<typename T, typename... S> void dbgm(T t, S... s){ cout << to_string(t) << " | "; dbgm(s...); } void dbgs(){;} template<typename T, typename... S> void dbgs(T t, S... s){ cout << t << " "; dbgs(s...);}
#define dbgr(...) cout << to_string(__VA_ARGS__) << endl;
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl;

#define ll long long
#define eb emplace_back

const ll N = 3e5+3, M = 1e9+7;
int let[N], a[N], pos[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;

    fou(i,1,n){
        cin >> a[i];
        pos[a[i]] = i;
    }

    int start = a[n];

    set<pair<int, int>> g;
    int pt = 0;
    fou(i,1,m){
        int u,v; cin >> u >> v;
        g.insert({u,v});
        if(v == a[n]){
            let[++pt] = u;
        }
    }

    m = pt;
    sort(let+1, let+1+m, greater<int>());
    // dbg(let,1,m);

    fou(i,1,m){
        fou(j,pos[let[i]],n-1){
            if(g.count(pair<int, int>{a[j], a[j+1]})){
                pos[a[j]]++;
                pos[a[j+1]]--;
                swap(a[j], a[j+1]);
            }
        }
    }
    // dbg(a,1,n);

    dbgs(n-pos[start]);
}


#include<bits/stdc++.h>
using namespace std;

#define fou(i,a,b) for(int i = a, _i = b; i <= _i; ++i)
#define fod(i,a,b) for(int i = a, _i = b; i >= _i; --i)

template<typename T> int SIZE(T (&t)){ return t.size(); } template<typename T, size_t N> int SIZE(T (&t)[N]){ return N; } string to_string(char t){ return "'" + string({t}) + "'"; } string to_string(bool t){ return t ? "true" : "false"; } string to_string(const string &t, int x1=0, int x2=1e9){ string ret = ""; for(int i = min(x1,SIZE(t)), _i = min(x2,SIZE(t)-1); i <= _i; ++i){ ret += t[i]; } return '"' + ret + '"'; } string to_string(const char* t){ string ret(t); return to_string(ret); } template<size_t N> string to_string(const bitset<N> &t, int x1=0, int x2=1e9){ string ret = ""; for(int i = min(x1,SIZE(t)); i <= min(x2,SIZE(t)-1); ++i){ ret += t[i] + '0'; } return to_string(ret); } template<typename T, typename... Coords> string to_string(const T (&t), int x1=0, int x2=1e9, Coords... C); template<typename T, typename S> string to_string(const pair<T, S> &t){ return "(" + to_string(t.first) + ", " + to_string(t.second) + ")"; } template<typename T, typename... Coords> string to_string(const T (&t), int x1, int x2, Coords... C){ string ret = "["; x1 = min(x1, SIZE(t)); auto e = begin(t); advance(e,x1); for(int i = x1, _i = min(x2,SIZE(t)-1); i <= _i; ++i){ ret += to_string(*e, C...) + (i != _i ? ", " : ""); e = next(e); } return ret + "]"; } template<int Index, typename... Ts> struct print_tuple{ string operator() (const tuple<Ts...>& t) { string ret = print_tuple<Index - 1, Ts...>{}(t); ret += (Index ? ", " : ""); return ret + to_string(get<Index>(t)); } }; template<typename... Ts> struct print_tuple<0, Ts...> { string operator() (const tuple<Ts...>& t) { return to_string(get<0>(t)); } }; template<typename... Ts> string to_string(const tuple<Ts...>& t) { const auto Size = tuple_size<tuple<Ts...>>::value; return print_tuple<Size - 1, Ts...>{}(t); } void dbgr(){;} template<typename Heads, typename... Tails> void dbgr(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgr(T...); } void dbgs(){;} template<typename Heads, typename... Tails> void dbgs(Heads H, Tails... T){ cout << H << " "; dbgs(T...); }
#define dbgv(...) cout << to_string(__VA_ARGS__) << endl;
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgv(__VA_ARGS__);
#define dbgr(...) dbgr(__VA_ARGS__); cout << endl;
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);

#define ll long long
#define eb emplace_back

const ll N = 3e5, M = 998244353;
int p[N] ;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;

    fou(i,1,n){
        cin >> p[i];
    }

    set<pair<int, int>> is;
    fou(i,1,m){
        int a, b; cin >> a >> b;
        is.insert({a,b});
    }

    int ans{0};
    vector<int> t{p[n]};
    fod(i,n-1,1){
        bool ok = 1;
        for(int j : t){
            ok &= is.count({p[i], j});
            if(!ok) {
                break;
            }
        }
        if(!ok){
            t.eb(p[i]);
        }
        else{
            ++ans;
        }
    }

    dbgs(ans);
}


#include<bits/stdc++.h>
using namespace std;

#define fou(i,a,b) for(int i = a, _i = b; i <= _i; ++i)
#define fod(i,a,b) for(int i = a, _i = b; i >= _i; --i)
template<typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T (&t)){ return t.size(); } string to_string(char b){ return "'" + string({b}) + "'"; } string to_string(bool b){ return (b ? "true" : "false"); } string to_string(const string &t, int x1=0, int x2=1e9){ string ret = ""; fou(i,min(x1,SIZE(t)),min(x2,SIZE(t)-1)){ ret += t[i]; } return '"' + ret + '"'; } string to_string(const char* t){ string ret(t); return to_string(ret); } template<size_t N> string to_string(const bitset<N> &t, int x1=0, int x2=1e9){ string ret = ""; fou(i,min(x1,SIZE(t)),min(x2,SIZE(t)-1)){ ret += t[i] + '0'; } return '"' + ret + '"'; } template<typename T, typename... Coords> string to_string(const T (&t), int x1=0, int x2=1e9, Coords... C); template<typename T, typename S> string to_string(const pair<T, S> (&t)){ return "(" + to_string(t.first) + ", " + to_string(t.second) + ")"; } template<typename T, typename... Coords> string to_string(const T (&t), int x1, int x2, Coords... C){ string ret = "["; x1 = min(x1, SIZE(t)); auto e = begin(t); advance(e, x1); fou(i,x1,min(x2,SIZE(t)-1)){ ret += (i != x1 ? ", " : "") + to_string(*e, C...); e = next(e); } return ret + "]"; } void dbgm(){;} template<typename T, typename... S> void dbgm(T t, S... s){ cout << to_string(t) << " | "; dbgm(s...); } void dbgs(){;} template<typename T, typename... S> void dbgs(T t, S... s){ cout << t << " "; dbgs(s...);}
#define dbgr(...) cout << to_string(__VA_ARGS__) << endl;
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl;

#define ll long long
#define eb emplace_back

const ll N = 3e5+3, M = 1e9+7;
int let[N], a[N], pos[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;

    fou(i,1,n){
        cin >> a[i];
        pos[a[i]] = i;
    }

    int start = a[n];

    set<pair<int, int>> g;
    int pt = 0;
    fou(i,1,m){
        int u,v; cin >> u >> v;
        g.insert({u,v});
        if(v == start){
            let[++pt] = u;
        }
    }

    m = pt;
    sort(let+1, let+1+m, greater<int>());
    // dbg(let,1,m);

    fou(i,1,m){
        fou(j,pos[let[i]],n-1){
            if(g.count(pair<int, int>{a[j], a[j+1]})){
                pos[a[j]]++;
                pos[a[j+1]]--;
                swap(a[j], a[j+1]);
            }
            else{
                break;
            }
        }
    }
    // dbg(a,1,n);

    dbgs(n-pos[start]);
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long double ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

ll n;

ll  sum, b[200500], ans;

ll a[200500];

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<ll, ll> bil;

ll cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(int i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(int i = 1; i <= n; ++i){

    ans += a[i] * (cur - bil[a[i] - 1] - bil[a[i]] - bil[a[i] + 1]) - (sum - ((a[i]-1) * 1 * bil[a[i] - 1]) - (a[i] * 1 * bil[a[i]]) - ((a[i]+1) * 1 * bil[a[i] + 1]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  cout << ans;

  return 0;
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long long ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

int n;

ll a[200500], sum, b[200500], ans;

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<int, ll> bil;

int cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(int i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(int i = 1; i <= n; ++i){

    ans += a[i] * 1ll * (cur - bil[a[i] - 1] - bil[a[i]] - bil[a[i] + 1]) - (sum - ((a[i]-1) * 1ll * bil[a[i] - 1]) - (a[i] * 1ll * bil[a[i]]) - ((a[i]+1) * 1ll * bil[a[i] + 1]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  cout << ans;

  return 0;
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long double ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

ll n;

ll  sum, b[200500], ans;

ll a[200500];

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<ll, ll> bil;

ll cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(int i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(int i = 1; i <= n; ++i){

    ans += a[i] * (cur - bil[a[i] - 1] - bil[a[i]] - bil[a[i] + 1]) - (sum - ((a[i]-1) * 1 * bil[a[i] - 1]) - (a[i] * 1 * bil[a[i]]) - ((a[i]+1) * 1 * bil[a[i] + 1]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  printf("%.0Lf\n", ans);

  return 0;
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long long ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

ll n;

ll a[200500], sum, b[200500], ans;

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<ll, ll> bil;

ll cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(ll i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(l i = 1; i <= n; ++i){

    ans += a[i] * 1ll * (cur - bil[a[i] - 1ll] - bil[a[i]] - bil[a[i] + 1ll]) - (sum - ((a[i]-1ll) * 1ll * bil[a[i] - 1ll]) - (a[i] * 1ll * bil[a[i]]) - ((a[i]+1ll) * 1ll * bil[a[i] + 1ll]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  cout << ans;

  return 0;
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long double ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

ll n;

ll  sum, b[200500], ans;

ll a[200500];

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<ll, ll> bil;

ll cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(int i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(int i = 1; i <= n; ++i){

    ans += a[i] * (cur - bil[a[i] - 1] - bil[a[i]] - bil[a[i] + 1]) - (sum - ((a[i]-1) * 1 * bil[a[i] - 1]) - (a[i] * 1 * bil[a[i]]) - ((a[i]+1) * 1 * bil[a[i] + 1]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  printf("%.0Lf\n", sum);

  return 0;
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long double ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

ll n;

ll a[200500], sum, b[200500], ans;

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<ll, ll> bil;

ll cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(ll i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(ll i = 1; i <= n; ++i){

    ans += a[i] * (cur - bil[a[i] - 1] - bil[a[i]] - bil[a[i] + 1]) - (sum - ((a[i]-1) * 1 * bil[a[i] - 1]) - (a[i] * 1 * bil[a[i]]) - ((a[i]+1) * 1 * bil[a[i] + 1]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  cout << ans;

  return 0;
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long double ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

ll n;

ll  sum, b[200500], ans;

int a[200500];

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<ll, ll> bil;

ll cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(ll i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(ll i = 1; i <= n; ++i){

    ans += a[i] * (cur - bil[a[i] - 1] - bil[a[i]] - bil[a[i] + 1]) - (sum - ((a[i]-1) * 1 * bil[a[i] - 1]) - (a[i] * 1 * bil[a[i]]) - ((a[i]+1) * 1 * bil[a[i] + 1]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  cout << ans;

  return 0;
}


/*
ID: simpgoo1
TASK: ride
LANG: C++14
*/
// 219263UI
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long long ll;

#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
// #define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int INF = 1e9 + 100;
const int MAXN = 3e5 + 100;

ll n;

ll a[200500], sum, b[200500], ans;

// void build(int v = 1, int tl = 1, int tr = n){
//   if( tl == tr ){
//     t[v] = a[tl];
//     return;
//   }
//   int tm = (tl + tr) >> 1;
//   build(v + v, tl, tm);
//   build(v + v + 1, tm + 1, tr);
//   t[v] = t[v + v] + t[v + v + 1];
// }

// buid upd(int pos, int v = 1, int tl = 1, int tr = n){

// }

unordered_map<ll, ll> bil;

ll cur;

int main(){
  // boost;
  file(task,0);
  srand(time(NULL));
  // freopen(task".in","r",stdin),freopen(task".out","w",stdout);

  cin >> n;

  for(ll i = 1; i <= n; ++i){
    cin >> a[i];
  }

  for(ll i = 1; i <= n; ++i){

    ans += a[i] * 1ll * (cur - bil[a[i] - 1ll] - bil[a[i]] - bil[a[i] + 1ll]) - (sum - ((a[i]-1ll) * 1ll * bil[a[i] - 1ll]) - (a[i] * 1ll * bil[a[i]]) - ((a[i]+1ll) * 1ll * bil[a[i] + 1ll]));

    // cout << ans << ' ';

    ++bil[a[i]];
    sum += a[i];
    ++cur;

  }

  cout << ans;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
ll n,i,k=1,p,fn[N],f[N],a[N],b[N],d,ans,s,q;
pll A,B,C,D;
map <ll,ll> mp;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++){
	    if(i==0){
	        mp[b[i]]=k;
	        continue;
	    }
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        if(p>2)A=read(p-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
ll n,i,k=1,p,fn[N],f[N],a[N],b[N],d,s,q;
long double ans;
pll A,B,C,D;
map <ll,ll> mp;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	mp[b[0]]=k;
	for(i=1;i<n;i++){
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        if(p>2)A=read(p-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout << fixed << setprecision(0) << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
int n,i,k=1,p,fn[N],f[N],a[N],b[N],d;
ll ans,s,q;
pll A,B,C,D;
map <ll,ll> mp;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++){
	    if(i==0){
	        mp[b[i]]=k;
	        continue;
	    }
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        if(p>2)A=read(p-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout<<ans;
}


#include <iostream>
using namespace std;
const int N = 200005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
int n,i,k,p,fn[N],f[N],a[N];
ll ans,s,q;
pll A,B,C,D;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];

	}
    for(i=n-1;i>=0;i--){
        update(a[i],a[i]);
        if(a[i]>2)A=read(a[i]-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(a[i]+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
int n,i,k,p,fn[N],f[N],a[N],b[N];
ll ans,s,q;
pll A,B,C,D;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++){
	    a[i]=upper_bound(b,b+n,a[i])-b;
	}
    for(i=n-1;i>=0;i--){
        update(a[i],a[i]);
        if(a[i]>2)A=read(a[i]-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(a[i]+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
int n,i,k=1,p,fn[N],f[N],a[N],b[N],d;
ll ans,s,q;
pll A,B,C,D;
map <ll,ll> mp;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	for(i=1;i<n;i++){
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	    b[i]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        if(a[i]>2)A=read(p-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
ll n,i,k=1,p,fn[N],f[N],a[N],b[N],d,s,q;
long double ans;
pll A,B,C,D;
map <ll,ll> mp;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++){
	    if(i==0){
	        mp[b[i]]=k;
	        continue;
	    }
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        if(p>2)A=read(p-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout << fixed << setprecision(0) << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
ll n,i,k=1,p,fn[N],f[N],a[N],b[N],d,s,q;
long double ans;
pll A,B,C,D;
map <ll,ll> mp;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	mp[b[0]]=k;
	for(i=1;i<n;i++){
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        A=p>2?read(p-2):{0,0};
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout << fixed << setprecision(0) << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
ll n,i,k=1,p,fn[N],f[N],a[N],b[N],d,s,q;
long double ans;
pll A,B,C,D,Z={0,0};
map <ll,ll> mp;
void update(int index,int value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	mp[b[0]]=k;
	for(i=1;i<n;i++){
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        A=p>2?read(p-2):Z;
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout<<fixed<<setprecision(0)<<ans;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
ll n,i,k=1,p,fn[N],f[N],a[N],b[N],d,ans,s,q;
pll A,B,C,D;
map <ll,ll> mp;
void update(int index,ll value){
    while(index<N){
        f[index]+=value;
        fn[index]+=1;
        index+=(-index&index);
    }
}
pll read(int index){
    s=0;q=0;
    while(index>0){
        s+=f[index];
        q+=fn[index];
        index-=(-index&index);
    }
    return {s,q};
}
int main() {
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++){
	    if(i==0){
	        mp[b[i]]=k;
	        continue;
	    }
	    d=b[i]-b[i-1];
	    if(d==1)k++;
	    if(d>=2)k+=2;
	    mp[b[i]]=k;
	}
    for(i=n-1;i>=0;i--){
        p=mp[a[i]];
        update(p,a[i]);
        if(p>2)A=read(p-2);
	    else A={0,0};
	    B=read(N-1);
	    C=read(p+1);
	    D={B.ff-C.ff,B.ss-C.ss};
	    ans+=(A.ff-a[i]*A.ss)+(D.ff-a[i]*D.ss);
    }
	cout<<ans;
}


#include <bits/stdc++.h>

#define ll long double
#define fort(i,a,b) for(long long i=(a);i<=(b);++i)
#define ford(i,a,b) for(long long  i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

map < long long ,long long > d;
long long n,a[N],sum[N];
ll tmp,a1,a2,a3,ans;

int main(){

    //pool();

    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        d[a[i]]++;
        a1=d[a[i]];
        a2=d[a[i]-1];
        a3=d[a[i]+1];
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    cout<<fixed<<setprecision(0)<<ans;
    return 0;
}


#include <bits/stdc++.h>

#define ll long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

multiset <ll> ss;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans;

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        a1=ss.count(a[i]);
        a2=ss.count(a[i]-1);
        a3=ss.count(a[i]+1);
        tmp=sum[i-1]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-1-a1-a2-a3)*a[i]-tmp;
        ss.insert(a[i]);
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 2000005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

ll n,a[N],sum[N],tmp,a1,a2,a3,ans,nT;
struct node{
    ll cnt;
    ll next[2];
} Tree[N];

ll AddNode(){
    ++nT;
    Tree[nT].cnt=
    Tree[nT].next[0]=
    Tree[nT].next[1]=0;
    return nT;
}

void up(ll x){
    ll r=0,i;
    ford(k,30,0) {
        i=(1<<k)&x;
        if (Tree[r].next[i]==0)
            Tree[r].next[i]=AddNode();
        Tree[r].cnt++;
        r=Tree[r].next[i];
    }
    Tree[r].cnt++;
}

ll get(ll x){
    ll r=0,i=0;
    ford(k,30,0){
        i=(1<<k)&x;
        if (Tree[r].next[i]==0) return 0;
        r=Tree[r].next[i];
    }
    return Tree[r].cnt;
}

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        up(a[i]);
        a1=get(a[i]);
        if (a[i]-1>=0) a2=get(a[i]-1);
        else a2=0;
        a3=get(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

multiset <ll> ss;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans;

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        ss.insert(a[i]);
        a1=ss.count(a[i]);
        a2=ss.count(a[i]-1);
        a3=ss.count(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

ll n,a[N],sum[N],tmp,a1,a2,a3,ans,nT;
struct node{
    ll cnt;
    ll next[2];
} Tree[N];

ll AddNode() {
++nT;
Tree[nT].cnt=
Tree[nT].next[0]=
Tree[nT].next[1]=0;
return nT;
}

void up(ll x){
    ll r=0;
    ford(k,30,0) {
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    Tree[r].cnt++;
}

ll get(ll x){
    ll r=0;
    ford(k,30,0){
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    return Tree[r].cnt;
}

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        up(a[i]);
        a1=get(a[i]);
        if (a[i]-1>=0) a2=get(a[i]-1);
        else a2=0;
        a3=get(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

multiset <int> ss;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans;

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        ss.insert(a[i]);
        a1=ss.count(a[i]);
        a2=ss.count(a[i]-1);
        a3=ss.count(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

multiset <ll> ss;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans,nT;
struct node{
    ll cnt;
    ll next[2];
} Tree[5000];

ll AddNode() {
++nT;
Tree[nT].cnt=
Tree[nT].next[0]=
Tree[nT].next[1]=0;
return nT;
}

void up(ll x){
    ll r=0;
    ford(k,30,0) {
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    Tree[r].cnt++;
}

ll get(ll x){
    ll r=0;
    ford(k,30,0) {
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    return Tree[r].cnt;
}

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    scanf("%lld",&n);
    fort(i,1,n){
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        up(a[i]);
        a1=get(a[i]);
        a2=get(a[i]-1);
        a3=get(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 500005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

multiset <ll> ss;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans;

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        a1=ss.count(a[i]);
        a2=ss.count(a[i]-1);
        a3=ss.count(a[i]+1);
        tmp=sum[i-1]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-1-a1-a2-a3)*a[i]-tmp;
        ss.insert(a[i]);
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

multiset <ll> ss;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans,nT;
struct node{
    ll cnt;
    ll next[2];
} Tree[50];

ll AddNode() {
++nT;
Tree[nT].cnt=
Tree[nT].next[0]=
Tree[nT].next[1]=0;
return nT;
}

void up(ll x){
    ll r=0;
    ford(k,30,0) {
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    Tree[r].cnt++;
}

ll get(ll x){
    ll r=0;
    ford(k,30,0) {
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    return Tree[r].cnt;
}

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    scanf("%lld",&n);
    fort(i,1,n){
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        up(a[i]);
        a1=get(a[i]);
        a2=get(a[i]-1);
        a3=get(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

ll n,a[N],sum[N],tmp,a1,a2,a3,ans,nT;
struct node{
    ll cnt;
    ll next[2];
} Tree[N];

ll AddNode() {
++nT;
Tree[nT].cnt=
Tree[nT].next[0]=
Tree[nT].next[1]=0;
return nT;
}

void up(ll x){
    ll r=0;
    ford(k,30,0) {
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    Tree[r].cnt++;
}

ll get(ll x){
    ll r=0;
    ford(k,30,0) {
    ll i=(x>>k) & 1;
    if (Tree[r].next[i]==0)
    Tree[r].next[i]=AddNode();
    Tree[r].cnt++;
    r=Tree[r].next[i];
    }
    return Tree[r].cnt;
}

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    scanf("%lld",&n);
    fort(i,1,n){
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        up(a[i]);
        a1=get(a[i]);
        a2=get(a[i]-1);
        a3=get(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

multiset <ll> ss;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans;

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    scanf("%lld",&n);
    fort(i,1,n){
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        ss.insert(a[i]);
        a1=ss.count(a[i]);
        a2=ss.count(a[i]-1);
        a3=ss.count(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

map <ll,ll> d;
ll n,a[N],sum[N],tmp,a1,a2,a3,ans;

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        d[a[i]]++;
        a1=d[a[i]];
        a2=d[a[i]-1];
        a3=d[a[i]+1];
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    cout<<ans;
    return 0;
}