#include<bits/stdc++.h>
using namespace std;
#define int long long

const int SIZE=1e5;

int N,M;
int P[SIZE],A[SIZE],B[SIZE],C[SIZE];

int dp[SIZE];
signed main(){
    scanf("%lld%lld",&N,&M);
    for(int i=0;i<M;i++)scanf("%lld",&P[i]),P[i]--;
    for(int i=0;i<N-1;i++)scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);

    for(int i=0;i<M-1;i++){
        dp[min(P[i],P[i+1])]++;
        dp[max(P[i],P[i+1])]--;
    }
    int ans=0;

    for(int i=0;i<N-1;i++){
        dp[i+1]+=dp[i];
        ans+=min(dp[i]*A[i],C[i]+dp[i]*B[i]);
    }

    printf("%lld\n",ans);
    return 0;
}