import core.stdc.stdio;
import std.algorithm;

void main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int[] p = new int[m];
	foreach(ref v;p)
		scanf("%d",&v);
	int[] a=new int[n-1],b=new int[n-1],c=new int[n-1];
	foreach(i;0..n-1)
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	int[] sum=new int[n-1];
	foreach(i;0..m-1){
		int s=p[i]-1,t=p[i+1]-1;
		if(s>t)
			swap(s,t);
		sum[s]++;
		if(t<n-1)
			sum[t]--;
	}
	foreach(i;1..n-1)
		sum[i]+=sum[i-1];
	long ans;
	foreach(i;0..n-1)
		ans+=min(cast(long)a[i]*sum[i],cast(long)b[i]*sum[i]+c[i]);
	printf("%lld\n",ans);
}