#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// ??????????????????????????????????????????????????°OK??§???
int main()
{
  int N, M; cin >> N >> M;
  int P[M]; FOR(i,0,M) cin >> P[i];
  ll A[N-1],B[N-1],C[N-1]; FOR(i,0,N-1) cin >> A[i] >> B[i] >> C[i];
  ll visit[N]; CLR(visit); // ???????????????(??????????????§)
  FOR(i,0,M-1) {
    int a = min(P[i], P[i+1]);
    int b = max(P[i], P[i+1]);
    a--;b--;
    visit[a]++;
    visit[b]--;
  }
  FOR(i,0,N-1) visit[i+1] += visit[i];
  ll ans = 0;
  FOR(i,0,N-1) ans += min(visit[i]*A[i], visit[i]*B[i]+C[i]);
  cout << ans << endl;
  return 0;
}