using System; using System.Collections; using System.Collections.Generic; using System.Linq; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int[] chk=new int[2]; int[] Tot=new int[N]; for(int i=0;i0&&chk[1]>0){ Console.WriteLine(-1); return; } int max=Tot.Max(); long ans=0; for(int i=0;iint.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }