#include <iostream>
#include <algorithm>
using namespace std;

int p[1000001];
long long co[1000001];
int a[1000001];
int b[2][1000001];

int main (){
  int n,m;
  cin >>n>>m;
  for(int i=1;i<=m;i++) cin >> p[i];
  for(int i=1;i<n;i++){
    cin >> a[i]>>b[0][i]>>b[1][i];
    co[i] = 0;
  }

  for(int i=1;i<m;i++){
    if(p[i]<p[i+1]){
      co[p[i]]++;
      co[p[i+1]]--;
    }else {
      co[p[i]]--;
      co[p[i+1]]++; 
    }
  }
  for(int i=2;i<n;i++) co[i] +=co[i-1];
  long long summin=0;
  for(int i=1;i<n;i++){
    summin+=min((long long)co[i]*a[i],(long long)co[i]*b[0][i]+b[1][i]);
  }
  cout <<summin<<endl;
  return 0;
}