#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
	ll n,m,p[100000],a[100000],b[100000],c[100000],f[100001];
	scanf("%lld %lld",&n,&m);
	for(ll i=0;i<m;i++){
		scanf("%lld",p+i);
		p[i]--;
	}
	for(ll i=0;i<n;i++) scanf("%lld %lld %lld",a+i,b+i,c+i);
	fill(f,f+n,0);
	ll pos = p[0];
	for(ll i=1;i<m;i++){
		if(p[i]>pos){
			f[pos]++;
			f[p[i]]--;
		}else{
			f[pos]--;
			f[p[i]]++;
		}
		pos = p[i];
	}
	for(ll i=0;i<n;i++) f[i+1] += f[i];
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ans += min(f[i]*a[i],c[i]+f[i]*b[i]);
	}
	printf("%lld\n",ans);
	return 0;
}