using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Yuki { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(); int p = s.Where(x => x.Equals("+")).Count(); int m = s.Where(x => x.Equals("-")).Count(); int k = n - p - m; int[] a = new int[k]; int b; int j = 0; for (int i = 0; i < n; i++) { if (int.TryParse(s[i], out b) || s[i] == "0") { a[j] = b; j++; } } Array.Sort(a); //max string st = ""; for (int i = a.Length - 1; i > m + p - 1; i--) { st += a[i].ToString(); } int max = int.Parse(st); for (int i = 0; i < p + m; i++) { if (i < m) { max = max - a[i]; } else { max = max + a[i]; } } Console.WriteLine(max); Console.WriteLine("-" + max.ToString()); } } }