N=gets.to_i T=gets.split.map &:to_i M=gets.to_i for k in 1..M L,R,D=gets.split.map &:to_i for i in L..R T[i-1]+=D end t=0 p=1 while p<=N if t+3>T[p-1] t=T[p-1]+3 else t+=3 end p+=1 end puts t end