#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,x,y,p[100000],pl[100001],su[100001];
	long long a,b,c,sum,xx,yy,mn;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&p[i]);
	}
	for(i=1;i<=n;i++){
		pl[i]=0; su[i]=0;
	}
	for(i=1;i<m;i++){
		x=p[i-1]; y=p[i];
		if(x>y) swap(x,y);
//printf("x=%d y=%d\n",x,y);	
		pl[x]++; pl[y]--;
	}
//for(i=1;i<=n;i++) printf("pl%d=%d\n",i,pl[i]);
	su[0]=0;
	for(i=1;i<=n;i++){
		su[i]=su[i-1]+pl[i];
//printf("su%d=%d\n",i,su[i]);
	}
	sum=0;
	for(i=1;i<n;i++){
		scanf("%lld %lld %lld",&a,&b,&c);
		xx=a*su[i];
		yy=b*su[i]+c;
//printf("xx=%d yy=%d\n",xx,yy);
		mn=min(xx,yy);
//printf("mn=%lld\n",mn);
		sum+=mn;
//printf("sum=%lld\n",sum);
	}
	printf("%lld\n",sum);
	return 0;
}