#include<iostream>
#include<algorithm>
using namespace std;
int n, m;
int s[100000];
int a[100000], b[100000], c[100000], l[100000];
int main()
{
	long long  ans = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> s[i]; s[i] = s[i] - 1;
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0; i < m - 1; i++) {
		l[max(s[i], s[i + 1])]--;
		l[min(s[i], s[i + 1])]++;
	}
	for (int i = 0; i < n - 1; i++) {
		l[i + 1] += l[i];
	}
	for (int i = 0; i < n; i++) {
		long long  ti = (long long)a[i] * l[i];
		long long  ic = (long long)b[i] * l[i] + c[i];
		ans += min(ti, ic);
	}
	cout << ans << endl;
}