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

const int maxn = (int) 1e5 + 5;

int n, m;
int BIT[maxn];

void update(int x, int val) {
    while (x < maxn) {
        BIT[x] += val;
        x += x & (-x);
    }
}

int get(int x) {
    int ret = 0;
    while (x > 0) {
        ret += BIT[x];
        x -= x & (-x);
    }
    return ret;
}

int main() {
    ///freopen("test.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    int cur, pre;
    cin >> pre;
    for (int i = 1; i < m; i ++) {
        cin >> cur;
        int x = min(cur, pre);
        int y = max(cur, pre);
        pre = cur;
        update(x, 1);
        update(y, -1);
    }
    long long res = 0;
    for (int i = 1; i < n; i ++) {
        long long a, b, c;
        cin >> a >> b >> c;
        int cnt = get(i);
        res += min(a * cnt, c + b * cnt);
    }
    cout << res << endl;
}