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

using LL = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<LL> P(M);
  for(auto& i: P) cin >> i;
  vector<LL> A(N + 1), B(N + 1), C(N + 1);
  for(int i = 1; i < N; ++i) cin >> A[i] >> B[i] >> C[i];

  vector<LL> s(N + 1);
  for(int i = 1; i < M; ++i) {
    if(P[i-1] < P[i]) {++s[P[i-1]]; --s[P[i]];}
    else              {++s[P[i]]; --s[P[i-1]];}
  }
  for(int i = 1; i < N; ++i) s[i] += s[i - 1];

  LL ans = 0;
  for(int i = 1; i < N; ++i) ans += min(A[i] * s[i], B[i] * s[i] + C[i]);
  cout << ans << endl;
}