#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N, M;
int cnt[100100];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N >> M;

    int prv = -1;
    for(int i=0;i<M;++i){
        int p;
        std::cin >> p;

        if(prv != -1){
            ++cnt[min(prv, p)];
            --cnt[max(prv, p)];
        }
        prv = p;
    }

    for(int i=1;i<N;++i){
        cnt[i+1] += cnt[i];
    }

    ll res = 0ll;
    for(int i=1;i<N;++i){
        int a, b, c;
        std::cin >> a >> b >> c;

        ll x = 1ll * a * cnt[i], y = 1ll * c + 1ll * b * cnt[i];
        res += min(x, y);
    }

    std::cout << res << std::endl;
}

