#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int A[999999];
int B[999999];
int brojac[999999];
int main()
{
	int n, m, i, j;
	int q = 1;
	int br = 0;
	int flagneg = 0;
	int zastava = 0;

	cin >> n >> m;

	for ( i = 0; i < n; i++)
	{
		cin >> A[i];
	}

	for (i = 0; i < m*2; i++)
	{
		cin >> B[i];
	}

	sort(B, B + m * 2);

	for ( j = 0; j < m*2; j++)
	{
		if (B[j] == q)
		{
			brojac[q]++;
		}
		else
		{
			q++;
			brojac[q]++;
		}
	}

	for ( i = 0; i < n; i++)
	{
		if (A[i] < 0)
		{
			flagneg = 1;
		}
		if (flagneg==1)
		{
			if (-A[i] > n)
			{
				zastava = 1;
				
			}
		}
		if (zastava == 1)
		{
			break;
			brojac[i + 1] = -brojac[i + 1];
		}
		
	}

	for ( i = 0; i < n; i++)
	{
		if (zastava)
		{
			brojac[i + 1] = -brojac[i + 1];
		}
	}

	for (i = 0; i < n; i++)
	{
		br += (A[i] * brojac[i+1]);
	}
	cout << br << endl;
}