#include <bits/stdc++.h>

using namespace std;

#define int long long

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)

int P[100010], A[100010], B[100010], C[100010];
int imos[100010];

signed main()
{
    int N, M; cin >> N >> M;

    rep(i, M) {
        cin >> P[i];
    }

    rep(i, N - 1) {
        cin >> A[i] >> B[i] >> C[i];
    }

    rep(i, M - 1) {
        if (P[i] < P[i + 1]) {
            imos[P[i]]++;
            imos[P[i + 1]]--;
        } else {
            imos[P[i + 1]]++;
            imos[P[i]]--;
        }
    }

    rep(i, N) imos[i + 1] += imos[i];

    int ans = 0;

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

    cout << ans << endl;
}