import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Random;
import java.util.StringTokenizer;

public class homework_aa implements Runnable {

	public static void main(String[] args) {
		new Thread(new homework_aa()).start();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (final Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (final Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(final boolean u, final String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(final int x, final int l, final int r, final String name) {
		myAssert(l <= x && x <= r, name + " not in bounds!!! " + x
				+ " not in [" + l + ".." + r + "]");
		return x;
	}

	String FNAME = "homework";

	private void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int[] t = new int[n];
		for (int i = 0; i < t.length; i++) {
			t[i] = nextInt();
		}
		int[] a = new int[n];
		while (m-- > 0) {
			a[nextInt() - 1] += 1 + 0 * nextInt();
		}
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			m = Math.max(m, a[i] == 0 ? t[i] : 0);
			sum += t[i];
		}
		out.println(sum - m);
	}

}
