Description Input Output Sample Input3 2 0 2 1 2 1 1 1 3Sample Output0 3 HintM,N<=3*10^5,Ai<=10^9 SourceCH Round#64 MFOI杯水题欢乐赛day1 By Gromah