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