#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

#define rep1(i,x) for(ll i=1;i<=(x);++i)

ll imos[100002];
ll P[100002];
ll A[100002], B[100002], C[100002];

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll N, M; cin >> N >> M;

	cin >> P[0];
	ll pre = P[0];

	rep1(i, M - 1) {
		cin >> P[i];
		if (pre < P[i]) {
			imos[pre]++; imos[P[i]]--;
		} else {
			imos[P[i]]++; imos[pre]--;
		}

		pre = P[i];
	}

	rep1(i, N - 1) cin >> A[i] >> B[i] >> C[i];

	ll ans = 0;

	rep1(i, N - 1) {
		imos[i] += imos[i - 1];
		ans += min(A[i] * imos[i], C[i] + B[i] * imos[i]);
	}

	cout << ans << endl;
}