#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int p[100000],a[100000],b[100000],c[100000],tetu[100001];
int main(void)
{
	int i,j,n,m;
	long long int sum[100001],kip,ic,kin;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++) scanf("%d",&p[i]);
	for(i=1;i<n;i++) scanf("%d %d %d",&a[i],&b[i],&c[i]);
	for(i=0;i<m;i++) tetu[i]=0;
	for(i=0;i<m-1;i++) {
		if(p[i]>p[i+1]) {
			tetu[p[i+1]]++;
			tetu[p[i]]--;
		}
		else {
			tetu[p[i]]++;
			tetu[p[i+1]]--;
		}
	}
	for(i=0;i<n;i++) sum[i]=0;
	for(i=1;i<n;i++) sum[i]+=sum[i-1]+tetu[i];
    kin=0;
	for(i=1;i<n;i++) {
		kip=(long long)a[i]*sum[i];
		ic=(long long)c[i]+(long long)b[i]*sum[i];
		if(kip>ic) kin+=ic;
		else kin+=kip;
	}
	printf("%lld\n",kin);
	return 0;
}