n, m = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
a = [0]*n
l.each_cons(2){|s, t| s,t = t,s if s > t; a[s-1] += 1; a[t-1] -= 1 }
(1...n-1).each{ |i| a[i] += a[i-1] }
sum = 0
(n-1).times do |i|
  p, q, r = gets.split.map(&:to_i)
  (p-q)*a[i] < r ? (sum += p*a[i]) : (sum += q*a[i]+r)
end
p sum