#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a; i<b;i++)
#define N_MAX 100000
#define M_MAX 100000

int main() {
	int N, A[N_MAX], B[N_MAX], C[N_MAX], M;
	int P[M_MAX];
	int thcou[N_MAX+1]={0};
	
	scanf("%d%d" ,&N, &M);
	FOR(i, 0, M){
		scanf("%d", &P[i]);
	}
	FOR(i, 0, N-1){
		scanf("%d%d%d", &A[i], &B[i], &C[i]);
	}
	FOR(i, 0,M-1){
		int x=P[i], y=P[i+1];
		if(x>y)
			swap(x, y);
		x--;
		y--;
		thcou[x]++;
		thcou[y]--;
	}
	FOR(i,1,N){
		thcou[i] += thcou[i-1];
	}
	
	
	long long int ans=0;
	FOR(i, 0,N){
		ans += min((long long)A[i]*thcou[i], (long long)B[i]*thcou[i] + C[i]);
	}
	
	printf("%lld\n", ans);
	
	
	return 0;
}