#include <bits/stdc++.h>

using namespace std;

#define int long long
static const int INF = 1LL<<61;

signed main() {
  int n, m, cum[100005] = {0}, pre;
  cin >> n >> m >> pre;
  for (int i = 1; i < m; ++i) {
    int p;
    cin >> p;
    int s = min(pre, p), t = max(pre, p);
    cum[s]++;
    cum[t]--;
    pre = p;
  }

  int sum = 0, ans = 0;
  for (int i = 1; i < n; ++i) {
    sum += cum[i];
    int a, b, c;
    cin >> a >> b >> c;

    if ((c / (a - b)) < sum) {
      ans += sum * b + c;
    } else {
      ans += sum * a;
    }
  }

  cout << ans << endl;
  
  return 0;
}