#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int N, M;
int P[100100];
int A[100100];
int B[100100];
int C[100100];
int T[100100];

int main() {
  cin >> N >> M;
  for (int i=0; i<M; i++) cin >> P[i];
  for (int i=0; i<N-1; i++) cin >> A[i] >> B[i] >> C[i];

  for (int i=1; i<M; i++) {
    int s = P[i-1]-1, d = P[i]-1;
    T[min(s, d)]++;
    T[max(s, d)]--;
  }
  long long ans = 0;
  long long t = 0;
  for (int i=0; i<N-1; i++) {
    t += T[i];
    ans += min(t*A[i], t*B[i] + C[i]);
  }
  cout << ans << "\n";
  return 0;
}