using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int itemCount = int.Parse(Reader.ReadLine()); string[] inpt = Reader.ReadLine().Split(' '); char[] enzansi = inpt.Where(a=>a.Equals("+") || a.Equals("-")).Select(a=>a[0]).OrderBy(a=>a).ToArray(); int[] numList = inpt.Where(a=>(!a.Equals("+")) && (!a.Equals("-"))).Select(a=>int.Parse(a)).OrderByDescending(a=>a).ToArray(); int saidaiKeta = numList.Length - enzansi.Length; List listSub = new List(); long ans1 = 0; listSub.Add(long.Parse(string.Join(string.Empty, numList.Take(saidaiKeta)))); listSub.AddRange(numList.Skip(saidaiKeta).Select(a=>(long)a)); ans1 = listSub[0]; listSub.RemoveAt(0); for(int i=0; i(); long ans2 = 0; enzansi = enzansi.Reverse().ToArray(); listSub.Add(long.Parse(string.Join(string.Empty, numList.Take(saidaiKeta)))); listSub.AddRange(numList.Skip(saidaiKeta).Select(a=>(long)a)); ans2 = listSub.Last(); listSub.RemoveAt(listSub.Count - 1); for(int i=0; i