#include <iostream>
#include <iterator>
#include <vector>
#include <functional>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;
typedef unsigned long long ull;

vector<ull> split(string& str){
	std::istringstream iss(str);
	std::string buf;
	vector<ull> res;
	while(std::getline(iss,buf,' ')){
		res.push_back(stoi(buf));
	}
	return res;
}

int main(){
	int n,m;
	cin>>n>>m;
	cin.ignore();
	vector<ull> vec(n-1);
	generate(vec.begin(),vec.end(),[]{return 0;});
	//?§??????????
	string line;
	getline(cin,line);
	vector<ull> t(split(line));
	for(int c = 0,e = t.size()-1;c < e;c++){
		int mx = max(t[c],t[c+1]),mn = min(t[c],t[c+1]);
		for(int mm = mn;mm < mx;mm++){
			vec[mm-1]++;
		}
	}
	vector<ull> av(n-1);
	vector<ull> bv(n-1);
	vector<ull> cv(n-1);

	for(int i = 0;i < n-1;i++){
		cin>>av[i]>>bv[i]>>cv[i];
	}
	ull res = 0;
	for(int i = 0;i < n-1;i++){
		if((av[i] - bv[i])*vec[i] < cv[i]){
			res += av[i]*vec[i];
		}else{
			res += bv[i]*vec[i]+cv[i];
		}
	}
	cout<<res<<endl;
	return 0;
}