#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int N, M;
int golist[100001];

struct eki {
	ll A, B, C;
};

eki e[100000];
ll ruisekiwa[100000];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++)cin >> golist[i], golist[i]--;
	for (int i = 0; i < N - 1; i++) {
		cin >> e[i].A >> e[i].B >> e[i].C;
	}

	for (int i = 0; i < M - 1; i++) {
		int from, to;
		if (golist[i] < golist[i + 1])from = golist[i], to = golist[i + 1];
		else from = golist[i + 1], to = golist[i];
		ruisekiwa[from]++, ruisekiwa[to]--;
		
	}
	for (int i = 1; i < N; i++)ruisekiwa[i] += ruisekiwa[i - 1];
	
	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans += min(e[i].A * ruisekiwa[i], e[i].B * ruisekiwa[i] + e[i].C);
	}
	cout << ans << endl;
	return 0;
}