using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int[] max1 = new int[n];
            int[] max2 = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = int.Parse(wh[0]);
                h[i] = int.Parse(wh[1]);
                if (i != 0)
                    max1[i] = Math.Max(h[i], h[i - 1]);
            }
            max1[0] = h[0];
            max2[n - 1] = h[n - 1];

            for (int i = h.Length - 1; i > 0; i--)
            {
                if (i != h.Length - 1)
                    max2[i] = Math.Max(h[i], h[i + 1]);
            }
            int[] result = new int[n];
            int sum = w.Sum();
            for (int i = 0; i < n; i++)
            {
                width = sum - w[i];
                if (i == 0)
                    height = max2[i + 1];
                else if (i == h.Length - 1)
                    height = max1[i - 1];
                else
                    height = Math.Max(max1[i - 1], max2[i + 1]);
                //Console.WriteLine(width + " " + height);
                result[i] = width * height;
                Console.Write(result[i] + " ");
            }
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = Convert.ToInt32(wh[0]);
                h[i] = Convert.ToInt32(wh[1]);
            }

            int[] result = new int[n];

            int[] max1 = new int[h.Length];
            Array.Copy(h, max1, h.Length);
            int[] max2 = new int[h.Length];
            Array.Copy(h, max2, h.Length);

            for (int i = 0; i < h.Length; i++)
            {
                if (i != 0)
                    max1[i] = Math.Max(max1[i], max1[i - 1]);
            }
            for (int i = h.Length - 1; i > 0; i--)
            {
                if (i != h.Length - 1)
                    max2[i] = Math.Max(max2[i], max2[i + 1]);
            }

            for (int j = 0; j < n; j++)
            {
                    width = w.Sum() - w[j];
                    if (j == 0)
                        height = max2[j + 1];
                    else if (j == h.Length - 1)
                        height = max1[j - 1];
                    else
                    height = Math.Max(max1[j - 1], max2[j + 1]);
                    //Console.WriteLine(width + " " + height);
                    result[j] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        public static int Max(int[] a, int j)
        {
            int[] max1 = a;
            int[] max2 = a;

                for (int i = 0; i < j; i++)
                {
                    if (i != 0)
                        max1[i] = Math.Max(max1[i], max1[i - 1]);
                }
            for (int i = a.Length-1; i > j; i--)
            {
                if (i != a.Length-1)
                    max2[i] = Math.Max(max2[i], max2[i + 1]);
            }
            int max = 0;
            if (j == 0)
                max = max2[j + 1];
            else if (j == a.Length - 1)
                max = max1[j - 1];
            else
                max = Math.Max(max2[j + 1], max1[j - 1]);
            return max;
        }

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = Convert.ToInt32(wh[0]);
                h[i] = Convert.ToInt32(wh[1]);
            }

            int[] result = new int[n];

            for (int j = 0; j < n; j++)
            {
                    width = w.Sum() - w[j];
                    height = Max(h, j);
                    //Console.WriteLine(width + " " + height);
                    result[j] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = int.Parse(wh[0]);
                h[i] = int.Parse(wh[1]);
            }

            int[] result = new int[n];

            int[] max1 = new int[h.Length];
            Array.Copy(h, max1, h.Length);
            int[] max2 = new int[h.Length];
            Array.Copy(h, max2, h.Length);

            for (int i = 0; i < h.Length; i++)
            {
                if (i != 0)
                    max1[i] = Math.Max(max1[i], max1[i - 1]);
            }

            for (int i = h.Length - 1; i > 0; i--)
            {
                if (i != h.Length - 1)
                    max2[i] = Math.Max(max2[i], max2[i + 1]);
            }
            int sum = w.Sum();
            for (int i = 0; i < n; i++)
            {
                width = sum - w[i];
                if (i == 0)
                    height = max2[i + 1];
                else if (i == h.Length - 1)
                    height = max1[i - 1];
                else
                    height = Math.Max(max1[i - 1], max2[i + 1]);
                //Console.WriteLine(width + " " + height);
                result[i] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        public static int Max(int[] a, int j)
        {
            int max = 0;
            for (int i = 0; i < a.Length; i++)
            {
                if (i != j)
                {
                    if (a[i] > max)
                        max = a[i];
                }
            }
            return max;
        }

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = Convert.ToInt32(wh[0]);
                h[i] = Convert.ToInt32(wh[1]);
            }

            int[] result = new int[n];

            for (int j = 0; j < n; j++)
            {
                    width = w.Sum() - w[j];
                    height = Max(h, j);
                    //Console.WriteLine(width + " " + height);
                    result[j] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = int.Parse(wh[0]);
                h[i] = int.Parse(wh[1]);
            }

            int[] result = new int[n];

            int[] max1 = new int[h.Length];
            Array.Copy(h, max1, h.Length);
            int[] max2 = new int[h.Length];
            Array.Copy(h, max2, h.Length);

            for (int i = 0; i < h.Length; i++)
            {
                if (i != 0)
                    max1[i] = Math.Max(max1[i], max1[i - 1]);
            }

            for (int i = h.Length - 1; i > 0; i--)
            {
                if (i != h.Length - 1)
                    max2[i] = Math.Max(max2[i], max2[i + 1]);
            }

            for (int i = 0; i < n; i++)
            {
                    width = w.Sum() - w[i];
                    if (i == 0)
                        height = max2[i + 1];
                    else if (i == h.Length - 1)
                        height = max1[i - 1];
                    else
                    height = Math.Max(max1[i - 1], max2[i + 1]);
                    //Console.WriteLine(width + " " + height);
                    result[i] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int[] max1 = new int[n];
            int[] max2 = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = int.Parse(wh[0]);
                h[i] = int.Parse(wh[1]);
                if (i != 0)
                    max1[i] = Math.Max(h[i], h[i - 1]);
            }
            max1[0] = h[0];

            for (int i = h.Length - 1; i > 0; i--)
            {
                if (i != h.Length - 1)
                    max2[i] = Math.Max(h[i], h[i + 1]);
            }
            int[] result = new int[n];

            for (int i = 0; i < n; i++)
            {
                    width = w.Sum() - w[i];
                    if (i == 0)
                        height = max2[i + 1];
                    else if (i == h.Length - 1)
                        height = max1[i - 1];
                    else
                    height = Math.Max(max1[i - 1], max2[i + 1]);
                    //Console.WriteLine(width + " " + height);
                    result[i] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        public static int Max(int[] a, int j)
        {
            int max1 = 0;
            int max2 = 0;
            if (j != 0)
            {
                for (int i = 0; i < j; i++)
                {
                    if (a[i] > max1)
                        max1 = a[i];
                }
            }
            for (int i = a.Length-1; i > j; i--)
            {
                if (a[i] > max2)
                    max2 = a[i];
            }
            return Math.Max(max1, max2);
        }

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = Convert.ToInt32(wh[0]);
                h[i] = Convert.ToInt32(wh[1]);
            }

            int[] result = new int[n];

            for (int j = 0; j < n; j++)
            {
                    width = w.Sum() - w[j];
                    height = Max(h, j);
                    //Console.WriteLine(width + " " + height);
                    result[j] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        public static int Max(int[] a, int j)
        {
            int[] max1 = new int[a.Length];
            Array.Copy(a, max1,a.Length);
            int[] max2 = new int[a.Length];
            Array.Copy(a, max2, a.Length);

                for (int i = 0; i < j; i++)
                {
                    if (i != 0)
                        max1[i] = Math.Max(max1[i], max1[i - 1]);
                }
            for (int i = a.Length-1; i > j; i--)
            {
                if (i != a.Length-1)
                    max2[i] = Math.Max(max2[i], max2[i + 1]);
            }
            int max = 0;
            if (j == 0)
                max = max2[j + 1];
            else if (j == a.Length-1)
                max = max1[j - 1];
            else
                max = Math.Max(max2[j + 1], max1[j - 1]);
            return max;
        }

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = Convert.ToInt32(wh[0]);
                h[i] = Convert.ToInt32(wh[1]);
            }

            int[] result = new int[n];

            for (int j = 0; j < n; j++)
            {
                    width = w.Sum() - w[j];
                    height = Max(h, j);
                    //Console.WriteLine(width + " " + height);
                    result[j] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        public static int Max(int[] a, int j)
        {
            int max1 = 0;
            int max2 = 0;

                for (int i = 0; i < j; i++)
                {
                    if (a[i] > max1)
                        max1 = a[i];
                }
            for (int i = a.Length-1; i > j; i--)
            {
                if (a[i] > max2)
                    max2 = a[i];
            }
            return Math.Max(max1, max2);
        }

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[] w = new int[n];
            int[] h = new int[n];

            int width = 0;
            int height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] wh = Console.ReadLine().Split(' ');
                w[i] = Convert.ToInt32(wh[0]);
                h[i] = Convert.ToInt32(wh[1]);
            }

            int[] result = new int[n];

            for (int j = 0; j < n; j++)
            {
                    width = w.Sum() - w[j];
                    height = Max(h, j);
                    //Console.WriteLine(width + " " + height);
                    result[j] = width * height;
            }

            for (int i = 0; i < n; i++)
                Console.Write(result[i] + " ");
            //Console.ReadKey();
        }
    }
}


using System;
using System.Linq;

namespace Test2 {
    class Program {
        struct Size {
            public int Width;
            public int Height;

            public Size(int width, int height) {
                Width = width;
                Height = height;
            }
        }

        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            Size[] faces = new Size[n];
            int widthSum, heightMax1, heightMax2;
            widthSum = heightMax1 = heightMax2 = 0;

            for (int i = 0; i < n; i++) {
                int[] size = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int w = size[0];
                int h = size[1];

                widthSum += w;
                if (h > heightMax2) {
                    heightMax1 = heightMax2;
                    heightMax2 = h;
                } else if (h > heightMax1) {
                    heightMax1 = h;
                }
                faces[i] = new Size(w, h);
            }

            for (int i = 0; i < n; i++) {
                int W = widthSum - faces[i].Width;
                int H;

                if (faces[i].Height == heightMax2) {
                    H = heightMax1;
                } else {
                    H = heightMax2;
                }

                Console.Write(string.Format("{0} ", W * H));
            }
        }
    }
}


using System;
using System.Collections.Generic;

class Program
{
static void Main(string[] args)
{
var count = int.Parse(Console.ReadLine());
List<int[]> friends = new List<int[]>(count);
int totalWidth = 0;
int maxHeight0 = 0;
int maxHeight1 = 0;
for (int i = 0; i < count; i++)
{
var str = Console.ReadLine().Split(' ');
int w = int.Parse(str[0]);
int h = int.Parse(str[1]);
friends.Add(new int[] { w, h });
totalWidth += w;
if (maxHeight0 <= h)
{
maxHeight1 = maxHeight0;
maxHeight0 = h;
}
else if (maxHeight1 < h)
maxHeight1 = h;
}
for (int i = 0; i < count; i++)
{
int[] arr = friends[i];
int w = totalWidth - arr[0];
int h = arr[1] == maxHeight0 ? maxHeight1 : maxHeight0;
Console.Write(w * h + " ");
}
}
}


using System;
using System.Collections.Generic;

namespace Fotos
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var widths = new List<int>();
            var maxWidth = 0;
            var maxHight1 = 0;
            var maxHight2 = 0;
            var indexOfaxHight1 = 0;

            for (int i = 0; i < n; i++)
            {
                var parametrs = Console.ReadLine().Split(' ');
                var w = int.Parse(parametrs[0]);
                var h = int.Parse(parametrs[1]);

                widths.Add(w);
                maxWidth += w;

                if (maxHight1 < h)
                {
                    maxHight2 = maxHight1;

                    indexOfaxHight1 = i;
                    maxHight1 = h;
                }
                else if(maxHight2 < h)
                {
                    maxHight2 = h;
                }
            }

            for (int i = 0; i < n; i++)
            {
                var maxHight = i == indexOfaxHight1 ? maxHight2 : maxHight1;
                Console.Write("{0} ", (maxWidth - widths[i]) * maxHight);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCodeCup
{
    class Program
    {
        static void Main(string[] args)
        {
            //var fileName = "input.txt";

            int n;
            var widthList = new List<int>();
            var heightList = new List<int>();

            //using(var streamReader = new StreamReader(fileName))
            //{
                n = int.Parse(Console.ReadLine());

                for (var i = 0; i < n; i++)
                {
                    var parts = Console.ReadLine().Split(' ');
                    widthList.Add(int.Parse(parts[0]));
                    heightList.Add(int.Parse(parts[1]));
                }
            //}

            for (var i = 0; i < n; i++)
            {
                var sumWidth = 0;
                var maxHeight = 0;
                for (var j = 0; j < n; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    sumWidth += widthList[j];
                    if (heightList[j] > maxHeight)
                    {
                        maxHeight = heightList[j];
                    }
                }
                Console.Write(String.Format("{0} ", sumWidth * maxHeight));
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCodeCup
{
    class Program
    {
        static void Main(string[] args)
        {
            //var fileName = "input.txt";

            int n = int.Parse(Console.ReadLine());
            var widthList = new int[n];
            var heightList = new int[n];
            var sumWidth = 0;
            var maxHeight = 0;
            var maxHeight2 = 0;

            //using(var streamReader = new StreamReader(fileName))
            //{

                for (var i = 0; i < n; i++)
                {
                    var parts = Console.ReadLine().Split(' ');
                    var width = int.Parse(parts[0]);
                    var height = int.Parse(parts[1]);

                    widthList[i] = width;
                    heightList[i] = height;

                    sumWidth += width;

                    if (height >= maxHeight)
                    {
                        maxHeight2 = maxHeight;
                        maxHeight = height;
                    }
                    else if (height > maxHeight2)
                    {
                        maxHeight2 = height;
                    }
                }
            //}

            for (var i = 0; i < n; i++)
            {
                var currentMaxHeight = heightList[i] == maxHeight ? maxHeight2 : maxHeight;
                Console.Write(String.Format("{0} ", (sumWidth - widthList[i]) * currentMaxHeight));
            }
        }
    }
}


using System;
using System.IO;

namespace VkCval
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            var n = Int32.Parse(sr.ReadLine());
            var array = new Tuple<long, long>[n];
            long totalW = 0L;
            long maxHIndx1 = 0L;
            long maxHIndx2 = 0L;
            for (var i = 0; i < n; i++)
            {
                var input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
                var tup = new Tuple<long, long>(Int64.Parse(input[0]), Int64.Parse(input[1]));
                array[i] = tup;
                totalW += tup.Item1;
                if (i == 1)
                {
                    maxHIndx1 = Math.Max(array[0].Item2, array[1].Item2) == array[0].Item2 ? 0 : 1;
                    maxHIndx2 = Math.Min(array[0].Item2, array[1].Item2) == array[0].Item2 ? 0 : 1;
                    if (maxHIndx1 == maxHIndx2)
                    {
                        maxHIndx1 = 0;
                        maxHIndx2 = 1;
                    }
                }
                if (i > 1)
                {
                    if (array[i].Item2 >= array[maxHIndx1].Item2)
                    {
                        maxHIndx2 = maxHIndx1;
                        maxHIndx1 = i;
                    }
                    else
                    {
                        if (array[i].Item2 > array[maxHIndx2].Item2)
                        {
                            maxHIndx2 = i;
                        }
                    }
                }
            }
            for (var i = 0; i < n; i++)
            {
                var width = totalW - array[i].Item1;
                var height = array[maxHIndx1].Item2;
                if (i == maxHIndx1)
                {
                    height = array[maxHIndx2].Item2;
                }
                sw.Write((totalW - array[i].Item1)*height + " ");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P1T2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] w =  new int[n]; int[] h = new int[n];
            int max = h[0]; int maxPrev = 0; int sum = 0; int indMax = 0;
            for (int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                h[i] = int.Parse(str[0]);
                w[i] = int.Parse(str[1]);
                if (w[i] >= max) { maxPrev = max; max = w[i]; indMax = i; }
                if (w[i] > maxPrev && w[i] != max) maxPrev = h[i];
                sum += h[i];
            }
            for (int i = 0; i < n; i++)
            {
                if (i==indMax)
                    Console.Write("{0} ", (sum-h[i])*maxPrev);
                else Console.Write("{0} ", (sum-h[i])*max);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P1T2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] w = new int[n]; int[] h = new int[n];
            int max = 0; int prevMax = 0; int maxInd = 0; long sum = 0;
            for (int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                w[i] = int.Parse(str[0]); h[i] = int.Parse(str[1]);
                sum += w[i];
                if (h[i] >= max) { prevMax = max; max = h[i]; maxInd = i; }
                else if (h[i] >= prevMax) prevMax = h[i];
            }
            for (int i = 0; i < n; i++)
            {
                if (i == maxInd) Console.Write((sum-w[i])*prevMax + " ");
                else Console.Write((sum-w[i])*max + " ");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] h = new int[n];
            int[] w = new int[n];

            int sum_w = 0;
            int max1 = 0;
            int max2 = 0;
            for (int i = 0; i < n; i++)
			{
			    int[] t = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                w[i] = t[0];
                h[i] = t[1];

                sum_w += t[0];

                if (max2 <= h[i])
                {
                    if (max1 <= h[i])
                    {
                        max2 = max1;
                        max1 = h[i];
                    }
                    else max2 = h[i];
                }
			}

            for(int i = 0; i < n; i++)
            {
                Console.Write("{0} ", (sum_w - w[i]) * ((max1 == h[i]) ? max2 : max1));
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GroupPhoto
{
    class Program
    {
        static void Main(string[] args)
        {
            var friendsCount = Convert.ToInt32(Console.ReadLine());
            var w = new int[friendsCount];
            var h = new Dictionary<int, int>();
            var areas = new int[friendsCount];

            for (var i = 0; i < friendsCount; i++)
            {
                var size = Console.ReadLine().Split(' ');
                w[i] = Convert.ToInt32(size[0]);
                h.Add(i, Convert.ToInt32(size[1]));
            }

            var totalW = w.Sum();
            var orderedH = h.OrderBy(s => s.Value).ToDictionary(k => k.Key, k => k.Value);
            int maxHKey = orderedH.Last().Key, maxHVal = orderedH.Last().Value,
                prevMaxValue = orderedH.ElementAt(friendsCount-2).Value;

            for (var i = 0; i < areas.Length; i++)
            {
                var areaW = totalW - w[i];
                var areaH = i == maxHKey ? prevMaxValue : maxHVal;

                areas[i] = areaW*areaH;
            }

            Console.WriteLine(string.Join(" ", areas));
        }
    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Learning
{
    class Program
    {
        static bool s_multiTest = false;
        static void Main(string[] args)
        {
            var o = Console.Out;
            var nTest = 1;
            if (s_multiTest)
            {
                nTest = NextInt();
            }

            for (int testId = 1; testId <= nTest; testId++)
            {
                Solve(testId, o);
            }
            Console.ReadLine();
        }

        private static void Solve(int testId, TextWriter o)
        {
            var n = NextInt();
            var w = new int[n];
            var h = new int[n];
            var sum = 0;
            for (var i = 0; i < n; i++)
            {
                w[i] = NextInt();
                h[i] = NextInt();
                sum += w[i];
            }

            MagicTree tree = new MagicTree(h);

            for (var i = 0; i < n; i++)
            {
                int weight = sum - w[i];
                if (i == 9) {
                    int a = 0;
                }

                int height = Math.Max(tree.RMQ(0, i - 1), tree.RMQ(i + 1, n-1));
               // o.WriteLine(Math.Max(tree.RMQ(0, i - 1), tree.RMQ(i + 1, n-1)));
               // o.WriteLine(tree.RMQ(0, i - 1));
               //  o.WriteLine(tree.RMQ(i + 1, n));

               if (i != 0)
                    o.Write(" ");
                o.Write(weight * height);
            }
        }
        class MagicTree
        {
            int[] max;
            int[] data;
            int n;

            public MagicTree(int[] data)
            {
                this.data = data;
                n = data.Length;
                max = new int[4 * n + 10];
                BuildTree(1, 0, n - 1);
            }

            private void BuildTree(int root, int rl, int rr)
            {
                if (rl == rr)
                {
                    max[root] = data[rl];
                }
                else
                {
                    int mid = (rl + rr) >> 1;
                    BuildTree(Left(root), rl, mid);
                    BuildTree(Right(root), mid + 1, rr);
                    max[root] = Math.Max(max[Left(root)], max[Right(root)]);
                }
            }

            public int RMQ(int left, int right)
            {
                return RMQ(1, 0, n - 1, left, right);
            }

            private int RMQ(int root, int rl, int rr, int left, int right)
            {
                if (left > rr || right < rl || rl > rr)
                {
                    return -1;
                }
                if (left == rl && right == rr)
                {
                    return max[root];
                }
                int mid = (rl + rr) >> 1;
                int max1 = RMQ(Left(root), rl, mid, left, Math.Min(mid, right));
                int max2 = RMQ(Right(root), mid + 1, rr, Math.Max(mid + 1, left), right);
                return Math.Max(max1, max2);
            }
            public int Left(int root)
            {
                return root << 1;
            }
            public int Right(int root)
            {
                return (root << 1) + 1; ;
            }
        }
        static int s_index = 0;
        static string[] s_tokens;
        private static string Next()
        {
            while (s_tokens == null || s_index == s_tokens.Length)
            {
                s_tokens = Console.ReadLine().Split(' ').ToArray();
                s_index = 0;
            }
            return s_tokens[s_index++];
        }

        private static string NextLine()
        {
            return Console.ReadLine();
        }
        private static int NextInt()
        {
            return Int32.Parse(Next());
        }

        private static long NextLong()
        {
            return Int64.Parse(Next());
        }
    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Learning
{
    class Program
    {
        static bool s_multiTest = false;
        static void Main(string[] args)
        {
            var o = Console.Out;
            var nTest = 1;
            if (s_multiTest)
            {
                nTest = NextInt();
            }

            for (int testId = 1; testId <= nTest; testId++)
            {
                Solve(testId, o);
            }
            Console.ReadLine();
        }

        private static void Solve(int testId, TextWriter o)
        {
            var n = NextInt();
            var w = new int[n];
            var h = new int[n];
            var sum = 0;
            for (var i = 0; i < n; i++)
            {
                w[i] = NextInt();
                h[i] = NextInt();
                sum += w[i];
            }

            MagicTree tree = new MagicTree(h);
            for (var i = 0; i < n; i++)
            {
                int weight = sum - w[i];
                int height = Math.Max(tree.RMQ(0, i - 1), tree.RMQ(i + 1, n));
                // o.WriteLine(tree.RMQ(0, i - 1));
                // o.WriteLine(tree.RMQ(i + 1, n));
                if (i != 0)
                    o.Write(" ");
                o.Write(weight * height);
            }
        }
        class MagicTree
        {
            int[] max;
            int[] data;
            int n;

            public MagicTree(int[] data)
            {
                this.data = data;
                n = data.Length;
                max = new int[4 * n + 10];
                BuildTree(1, 0, n - 1);
            }

            private void BuildTree(int root, int rl, int rr)
            {
                if (rl == rr)
                {
                    max[root] = data[rl];
                }
                else
                {
                    int mid = (rl + rr) >> 1;
                    BuildTree(Left(root), rl, mid);
                    BuildTree(Right(root), mid + 1, rr);
                    max[root] = Math.Max(max[Left(root)], max[Right(root)]);
                }
            }

            public int RMQ(int left, int right)
            {
                return RMQ(1, 0, n - 1, left, right);
            }

            private int RMQ(int root, int rl, int rr, int left, int right)
            {
                if (left > rr || right < rl)
                {
                    return -1;
                }
                if (left == rl && right == rr)
                {
                    return max[root];
                }
                int mid = (rl + rr) >> 1;
                int max1 = RMQ(Left(root), rl, mid, left, Math.Min(mid, right));
                int max2 = RMQ(Right(root), mid + 1, right, Math.Max(mid + 1, left), right);
                return Math.Max(max1, max2);
            }
            public int Left(int root)
            {
                return root << 1;
            }
            public int Right(int root)
            {
                return (root << 1) + 1; ;
            }
        }
        static int s_index = 0;
        static string[] s_tokens;
        private static string Next()
        {
            while (s_tokens == null || s_index == s_tokens.Length)
            {
                s_tokens = Console.ReadLine().Split(' ').ToArray();
                s_index = 0;
            }
            return s_tokens[s_index++];
        }

        private static string NextLine()
        {
            return Console.ReadLine();
        }
        private static int NextInt()
        {
            return Int32.Parse(Next());
        }

        private static long NextLong()
        {
            return Int64.Parse(Next());
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp9 {
    class Program {

        struct Size {
            public int W { get; set; }
            public int H { get; set; }

            public Size(int w, int h) {
                W = w;
                H = h;
            }
        }

        static void Main(string[] args) {

            int count = int.Parse(Console.ReadLine());
            Dictionary<int, Size> sizes = new Dictionary<int, Size>(count);
            List<int> heights = new List<int>(count);

            for(int i = 0; i < count; i++) {
                string[] words = Console.ReadLine().Split();
                int width = int.Parse(words[0]);
                int height = int.Parse(words[1]);
                sizes.Add(i, new Size(width, height));
                heights.Add(height);
            }

            int sumWidth = sizes.Sum(pair => pair.Value.W);
            var sortedHeights = heights.OrderByDescending(height => height).ToList();

            for(int i = 0; i < count; i++) {
                int currentWidth = sumWidth - sizes[i].W;
                int currentHeight = (sizes[i].H == sortedHeights[0]) ? sortedHeights[1] : sortedHeights[0];
                Console.Write($"{currentWidth * currentHeight} ");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace lab2
{
    class Program
    {
        struct Person
        {
            public long H;
            public long W;
        }

        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());
            var list = new List<Person>();
            long max1;
            long max2;
            long maxindex = 0;

            max1 = long.MinValue;
            max2 = long.MinValue;

            for (var i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                var x = s.Split(' ');
                list.Add(new Person
                {
                    W = Convert.ToInt64(x[0]),
                    H = Convert.ToInt64(x[1])
                });
                if (list[i].H > max1)
                {
                    max2 = max1;
                    max1 = list[i].H;
                    maxindex = i;
                }
                else
                {
                    if (list[i].H > max2)
                        max2 = list[i].H;
                }
            }

            var sum = list.Aggregate<Person, long>(0, (current, person) => current + person.W);

            for (var i = 0; i < n; i++)
            {
                long rez;
                if (i == maxindex)
                {
                    rez = max2*(sum - list[i].W);
                }
                else
                {
                    rez = max1 * (sum - list[i].W);
                }
                Console.Write("{0} ", rez);
            }

        }
    }
}


using System;

namespace Task_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var result = "";

            int i,
                width = 0,
                height;

            var s = new string[n];

            var k = new string[n];

            for (i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
            }

            for (i = 0; i < n; i++)
            {
                s.CopyTo(k, 0);

                k[i] = "0 0";

                int maxHeight = 0;

                for (int j = 0; j < n; j++)
                {
                    var t = k[j].Split(' ');

                    var w = int.Parse(t[0]);

                    var h = int.Parse(t[1]);

                    if (h > maxHeight)
                    {
                        maxHeight = h;
                    }

                    width += w;
                }

                height = maxHeight;

                result += (width * height) + " ";

                width = 0;
            }

            Console.WriteLine(result);
        }
    }
}


using System;

namespace Task_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var s = new int[n,2];

            int maxHeight = 0,
                secondMaxHeight = 0,
                z = 0;
            long width = 0;

            for (int i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split(' ');

                s[i, 0] = int.Parse(t[0]);
                s[i, 1] = int.Parse(t[1]);

                width += s[i, 0];

                if (s[i, 1] > maxHeight)
                {
                    secondMaxHeight = maxHeight;
                    maxHeight = s[i, 1];
                    z = i;
                }
                else if (s[i, 1] > secondMaxHeight)
                {
                    secondMaxHeight = s[i, 1];
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (i == z)
                {
                    Console.Write(((width - s[i, 0])*secondMaxHeight) + " ");
                }

                else Console.Write(((width - s[i, 0]) * maxHeight) + " ");
            }
        }
    }
}


using System;

namespace Task_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var result = "";

            var s = new int[n,2];

            int maxHeight = 0,
                secondMaxHeight = 0,
                width = 0,
                z = 0;

            for (int i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split(' ');

                s[i, 0] = int.Parse(t[0]);
                s[i, 1] = int.Parse(t[1]);

                width += s[i, 0];

                if (s[i, 1] >= maxHeight)
                {
                    secondMaxHeight = maxHeight;
                    maxHeight = s[i, 1];
                    z = i;
                }

                if (s[i, 1] < maxHeight && s[i, 1] >= secondMaxHeight)
                {
                    secondMaxHeight = s[i, 1];
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (i == z)
                {
                    result += ((width - s[i, 0])*secondMaxHeight) + " ";
                }

                else result += ((width - s[i, 0]) * maxHeight) + " ";
            }

            Console.WriteLine(result);
        }
    }
}


using System;

namespace Task_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var result = "";
            int i,
                width = 0,
                height = 0;

            var s = new string[n];

            var k = new string[n];

            int maxHeight = 0;

            for (i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
            }

            for (i = 0; i < n; i++)
            {
                s.CopyTo(k,0);

                k[i] = "0 0";

                for (int j = 0; j < n; j++)
                {
                    var t = k[j].Split(' ');

                    var w = int.Parse(t[0]);

                    var h = int.Parse(t[1]);

                    if (h > maxHeight)
                    {
                        maxHeight = h;
                    }

                    width += w;
                }

                height = maxHeight;

                result += (width * height).ToString() + " ";

                height = 0;
                width = 0;
            }

            Console.WriteLine(result);
        }
    }
}


using System;

namespace Task_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var result = "";

            var s = new int[n,2];

            int maxHeight = 0,
                secondMaxHeight = 0,
                width = 0,
                z = 0;

            for (int i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split(' ');

                s[i, 0] = int.Parse(t[0]);
                s[i, 1] = int.Parse(t[1]);

                width += s[i, 0];

                if (s[i, 1] > maxHeight)
                {
                    maxHeight = s[i, 1];
                    z = i;
                }

                if (s[i, 1] < maxHeight && s[i, 1] >= secondMaxHeight)
                {
                    secondMaxHeight = s[i, 1];
                }

            }

            for (int i = 0; i < n; i++)
            {
                if (i == z)
                {
                    result += ((width - s[i, 0])*secondMaxHeight) + " ";
                }

                else result += ((width - s[i, 0]) * maxHeight) + " ";
            }

            Console.WriteLine(result);
        }
    }
}


using System;

namespace Task_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var result = "";

            var s = new int[n][];

            for (int i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split(' ');

                s[i] = new int[2];
                s[i][0] = int.Parse(t[0]);
                s[i][1] = int.Parse(t[1]);
            }

            for (int i = 0; i < n; i++)
            {
                var a = s[i][0];
                s[i][0] = 0;
                var b = s[i][1];
                s[i][1] = 0;

                int maxHeight = 0,
                    width = 0;

                for (int j = 0; j < n; j++)
                {
                    width += s[j][0];

                    if (s[j][1] > maxHeight)
                    {
                        maxHeight = s[j][1];
                    }
                }

                result += (width*maxHeight) + " ";

                s[i][0] = a;
                s[i][1] = b;
            }

            Console.WriteLine(result);
        }
    }
}


using System;

namespace Task_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            string result = "";

            var s = new string[n];

            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
            }

            int width = 0, height = 0;

            for (int i = 0; i < n; i++)
            {
                string[] k = new string[n];

                for (int j = 0; j < n; j++)
                {
                    k[j] = s[j];
                }

                k[i] = "0 0";

                int maxHeight = 0;

                for (int j = 0; j < n; j++)
                {
                    var t = k[j].Split(' ');

                    var w = int.Parse(t[0]);

                    var h = int.Parse(t[1]);

                    if (h > maxHeight)
                    {
                        maxHeight = h;
                    }

                    width += w;
                }

                height = maxHeight;

                result+= (width*height) + " ";

                height = 0;
                width = 0;
            }

            Console.WriteLine(result);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace probnikShark
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int n = Convert.ToInt32(str1);
            int [] w = new int[n];
            int [] h = new int[n];
            for (int i = 0; i < n; i++)
            {
                string mas2 = Console.ReadLine();
                string[] mas1 = mas2.Split();
                w[i] = Convert.ToInt32(mas1[0]);
                h[i] = Convert.ToInt32(mas1[1]);
            }
            int w1;
            int h1;
            int max = 0;
            int sum = 0;

            for (int i = 0; i < n; i++)
            {
                w1 = w[i];
                h1 = h[i];
                w[i] = 0;
                h[i] = 0;
                max = 0;
                sum = 0;
                for (int j = 0; j < n; j++)
                {
                    if (max < h[j])
                        max = h[j];
                    sum += w[j];
                }
                Console.Write((sum * max)+" ");
                w[i] = w1;
                h[i] = h1;
            }

                Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace probnikShark
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int n = Convert.ToInt32(str1);
            int [] w = new int[n];
            int [] h = new int[n];
            int sum = 0;
            int max1 = 0;
            int max2 = 0;

            int i1 = 0;
            int i2 = 0;
            for (int i = 0; i < n; i++)
            {
                string mas2 = Console.ReadLine();
                string[] mas1 = mas2.Split();
                w[i] = Convert.ToInt32(mas1[0]);
                sum += w[i];
                h[i] = Convert.ToInt32(mas1[1]);

                if (max1 <= h[i])
                {
                    max2 = max1;
                    i2 = i1;
                    max1 = h[i];
                    i1 = i;
                }
                else if (max2 < h[i])
                {
                    max2 = h[i];
                    i2 = i;
                }

            }

            int sum1 = 0;
            for (int i = 0; i < n; i++)
            {
                sum1 = sum;
                sum -= w[i];
                h[i] = 0;

                if (i != i1)
                {
                    Console.Write((sum * max1) + " ");
                }
                else
                {
                    Console.Write((sum * max2) + " ");
                }
                sum = sum1;
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace probnikShark
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int n = Convert.ToInt32(str1);
            int [] w = new int[n];
            int [] h = new int[n];
            for (int i = 0; i < n; i++)
            {
                string mas2 = Console.ReadLine();
                string[] mas1 = mas2.Split();
                w[i] = Convert.ToInt32(mas1[0]);
                h[i] = Convert.ToInt32(mas1[1]);
            }
            int w1;
            int h1;
            int max = 0;
            int sum = 0;

            for (int i = 0; i < n; i++)
            {
                w1 = w[i];
                h1 = h[i];
                w[i] = 0;
                h[i] = 0;
                max = 0;
                sum = 0;
                for (int j = 0; j < n; j++)
                {
                    if (max < h[j])
                        max = h[j];
                    sum += w[j];
                }
                Console.Write((sum * max)+" ");
                w[i] = w1;
                h[i] = h1;
            }

        }
    }
}


using System;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> H = new List<int>();
            List<int> W = new List<int>();

            int n = int.Parse(Console.ReadLine());
            int sumW = 0;
            int max1 = -1;
            int max2 = -1;
            int countMax1 = 0;
            //for (int i = 0; i < n; i++)
            //{
            //    H.Add(0);
            //    W.Add(0);
            //}

            for (int i = 0; i < n; i++)
            {
                string[] temp = Console.ReadLine().Split(' ');

                W.Add(int.Parse(temp[0]));
                H.Add(int.Parse(temp[1]));

                sumW += W[i];

                if (max1 == -1 || H[i] > max1)
                {
                    max2 = max1;
                    max1 = H[i];
                    countMax1 = 1;
                }
                else if (max1 == H[i])
                    countMax1 = 2;
                else if (max2 == -1 || H[i] > max2)
                    max2 = H[i];

            }

            for (int i = 0; i < n-1; i++)
            {
                if (H[i] == max1 && countMax1 == 1)
                    Console.Write("{0} ", max2 * (sumW - W[i]));
                else
                    Console.Write("{0} ", max1 * (sumW - W[i]));
            }
            if (H[n-1] == max1 && countMax1 == 1)
                Console.Write("{0} ", max2 * (sumW - W[n - 1]));
            else
                Console.Write("{0} ", max1 * (sumW - W[n - 1]));
        }
    }
}


using System;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> H = new List<int>();
            List<int> W = new List<int>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                H.Add(0);
                W.Add(0);
            }

            for (int i = 0; i < n; i++)
            {
                string[] temp = Console.ReadLine().Split(' ');

                for (int j = 0; j < n; j++)
                {
                    if (j != i)
                    {
                        W[j] += int.Parse(temp[0]);
                        if (int.Parse(temp[1]) > H[j])
                            H[j] = int.Parse(temp[1]);
                    }
                }
            }

            for (int i = 0; i < n-1; i++)
            {
                Console.Write("{0} ", H[i]*W[i]);
            }
            Console.WriteLine("{0}", H[n-1]*W[n-1]);
        }
    }
}


using System;

namespace ConsoleApplication7
{
    class Program
    {
        const int N = 200005;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int i = 0, m = 0, m1 = 0, a = 0;
            int[] h = new int[N];
            int[] w = new int[N];
            string[] s = null;
            for(i=1;i<=n;i++)
            {
                s = Console.ReadLine().Split(' ');
                w[i]=Convert.ToInt32(s[0]);
                h[i]=Convert.ToInt32(s[1]);
                if (h[m] <= h[i])
                {
                    m1 = m;
                    m = i;
                }
                else if (h[m1] <= h[i])
                    m1 = i;
                a += w[i];
            }
            for (i = 1; i <= n; i++)
            {
                if (m == i)
                    Console.Write((a - w[i]) * h[m1]+" ");
                else Console.Write((a - w[i]) * h[m]+" ");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] wh = new int[n, 2];
            string[] spl = Console.ReadLine().Split(' ');
            wh[0, 0] = int.Parse(spl[0]);
            wh[0, 1] = int.Parse(spl[1]);
            int sum = wh[0, 0];
            for (int i = 1; i < n; i++)
            {
                string[] split = Console.ReadLine().Split(' ');
                wh[i, 0] = int.Parse(split[0]);
                wh[i, 1] = int.Parse(split[1]);
                sum += wh[i, 0];
                int k = i;
                int temp;
                int temp2;
                while (k != 0)
                {
                    if (wh[k, 1] >= wh[k - 1, 1])
                    {
                        temp = wh[k, 1];
                        temp2 = wh[k, 0];
                        wh[k, 1] = wh[k - 1, 1];
                        wh[k, 0] = wh[k - 1, 0];
                        wh[k - 1, 1] = temp;
                        wh[k - 1, 0] = temp2;
                    }
                    k--;
                }

            }
            for (int i = 0; i < n; i++)
            {
                int x = sum - wh[i, 0];
                int y = 0;
                if (i == 0)
                    y = wh[1, 1];
                else
                    y = wh[0, 1];
                Console.Write(x * y+" ");

            }

            Console.ReadLine();
        }
    }
}


using System;

namespace ConsoleApplication7
{
    class Program
    {
        const int N = 200005;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int i = 0, m = 0, m1 = 0, a = 0;
            int[] h = new int[N];
            int[] w = new int[N];
            string[] s = null;
            for(i=1;i<=n;i++)
            {
                s = Console.ReadLine().Split(' ');
                w[i]=Convert.ToInt32(s[0]);
                h[i]=Convert.ToInt32(s[1]);
                if (h[m] <= h[i])
                {
                    m1 = m;
                    m = i;
                }
                else if (h[m1] <= h[i])
                    m1 = i;
                a += w[i];
            }
            for (i = 1; i <= n; i++)
            {
                if (m == i)
                    Console.Write((a - w[i]) * h[m1]);
                else Console.Write((a - w[i]) * h[m]);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] wh = new int[n,2];
            string[] spl = Console.ReadLine().Split(' ');
            wh[0,0] = int.Parse(spl[0]);
            wh[0,1] = int.Parse(spl[1]);
            int sum = wh[0, 0];
            int max = wh[0,1];
            int max2 = 0;
            for (int i=1;i<n;i++)
            {
                string [] split = Console.ReadLine().Split(' ');
                wh[i,0] = int.Parse(split[0]);
                wh[i,1] = int.Parse(split[1]);
                sum += wh[i, 0];
                if (wh[i, 1] >= max)
                    {
                        max2 = max;
                        max = wh[i, 1];
                    }
                 else
                    if (wh[i,1]>=max2)
                        max2=wh[i,1];

            }
            for (int i=0;i<n;i++)
            {
                int x = sum - wh[i, 0];
                int y=0;
                if (wh[i,1] == max)
                    y = max2;
                else
                    y = max;
                Console.Write(x*y+" ");

            }
        }
    }
}


using System;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] wh = new string[n];
            int[] a = new int[n];
            int[] b = new int[n];
            string s = "";
            int w = 0, c = 0, k = 0; ;
            for (int i = 0; i < n; i++)
            {
                wh = Console.ReadLine().Split(' ');

                w += Convert.ToInt32(wh[0]);
                a[i] = Convert.ToInt32(wh[0]);
                b[i] = Convert.ToInt32(wh[1]);
            }
            for (int i = 0; i < n; i++)
            {
                k = 0; c = 0;
                c = w-a[i];
                for (int j = 0; j < n; j++)
                {
                    if (j != i)
                    {
                        if (b[j] > k)
                            k = b[j];
                    }
                }
                c = c * k;
                s += c.ToString() + " ";
            }
            Console.WriteLine(s);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCUP2015B
{
    class Program
    {

        static int IntParse(string str)
        {
            int res = 0;
            for (int i = 0; i < str.Length; ++i)
            {
                res = 10 * res + (str[i] - '0');
            }
            return res;
        }
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            var arr = new Tuple<int, int>[n];
            long i = 0, sum = 0;
            while (i < n)
            {
                var str = Console.ReadLine().Split(' ').Select(IntParse);

                sum += str.ElementAt(0);
                arr[i] = new Tuple<int, int>(str.ElementAt(0), str.ElementAt(1));

                ++i;
            }

            var sortedheights = arr.OrderByDescending(x => x.Item2).Select(x => x.Item2);

            for(i=0;i<n;++i)
            {
                if(arr[i].Item2==sortedheights.First())
                {
                    Console.Write("{0} ",(sum - arr[i].Item1) * (sortedheights.ElementAt(1)));
                }
                else

                    Console.Write("{0} ", (sum - arr[i].Item1) * (sortedheights.First()));
            }
            //Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCUP2015B
{
    class Program
    {

        static int IntParse(string str)
        {
            int res = 0;
            for (int i = 0; i < str.Length; ++i)
            {
                res = 10 * res + (str[i] - '0');
            }
            return res;
        }
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("open.txt"));
            //Console.SetOut(new StreamWriter("f.txt"));
            long n = long.Parse(Console.ReadLine());

            var arr = new int[2*n];
            var heights = new int[n];
            long i = 0, sum = 0;

            n *= 2;
            while (i < n)
            {
                var str = Console.ReadLine().Split(' ').Select(IntParse);

                sum += arr[i] = str.ElementAt(0);

                heights[i / 2] = arr[i+1] = str.ElementAt(1);

                i +=2;
            }

            var sortedheights = heights.OrderByDescending(x => x);
            var first = sortedheights.First();
            var second = sortedheights.ElementAt(1);

            for(i=0;i<n;i+=2)
            {
                if (arr[i + 1] == first)
                {
                    Console.Write("{0} ",(sum - arr[i]) * second);
                }
                else

                    Console.Write("{0} ", (sum - arr[i]) * first);
            }
            //Console.ReadLine();
        }
    }
}


namespace Photo
{
    using System;

    public class Program
    {
        public static void Main()
        {
            string line;
            var count = Convert.ToInt32(Console.ReadLine());
            var friendList = new ushort[count, 2];
            var sumWidth = 0;
            ushort maxHeight = 0;
            var k = 0;
            for (var i = 0; i < count; i++)
            {
                line = Console.ReadLine();
                var temp = line.Split();
                friendList[i, 0] = ushort.Parse(temp[0]);
                friendList[i, 1] = ushort.Parse(temp[1]);
                sumWidth += friendList[i, 0];
                if (friendList[i, 1] > maxHeight)
                {
                    maxHeight = friendList[i, 1];
                    k = i;
                }
            }

            ushort maxPreHeight = 0;
            for (var j = 0; j < k; j++)
            {
                if (friendList[j, 1] > maxPreHeight)
                {
                    maxPreHeight = friendList[j, 1];
                }
            }

            for (var j = k + 1; j < count; j++)
            {
                if (friendList[j, 1] > maxPreHeight)
                {
                    maxPreHeight = friendList[j, 1];
                }
            }

            var s = maxHeight * sumWidth;
            for (var i = 0; i < count; i++)
            {
                if (friendList[i, 1] != maxHeight)
                {
                    Console.Write((s - (friendList[i, 0] * maxHeight)) + " ");
                }
                else
                {
                    Console.Write((maxPreHeight * (sumWidth - friendList[i, 0])) + " ");
                }
            }
        }
    }
}


namespace Photo
{
    using System;

    public class Program
    {
        public static void Main()
        {
            string line;
            var count = Convert.ToInt32(Console.ReadLine());
            var friendList = new ushort[count, 2];
            var sumWidth = 0;
            ushort maxHeight = 0;
            for (var i = 0; i < count; i++)
            {
                line = Console.ReadLine();
                var temp = line.Split();
                friendList[i, 0] = ushort.Parse(temp[0]);
                friendList[i, 1] = ushort.Parse(temp[1]);
                sumWidth += friendList[i, 0];
                if (friendList[i, 1] > maxHeight)
                {
                    maxHeight = friendList[i, 1];
                }
            }

            var s = maxHeight * sumWidth;
            for (var i = 0; i < count; i++)
            {
                var tmpMaxHeight = 0;
                if (friendList[i, 1] == maxHeight)
                {
                    for (var j = 0; j < count; j++)
                    {
                        if (i == j)
                        {
                            continue;
                        }

                        if (friendList[j, 1] > tmpMaxHeight)
                        {
                            tmpMaxHeight = friendList[j, 1];
                        }
                    }

                    Console.Write((tmpMaxHeight * (sumWidth - friendList[i, 0])) + " ");
                }
                else
                {
                    Console.Write((s - (friendList[i, 0] * maxHeight)) + " ");
                }
            }
        }
    }
}


namespace Photo
{
    using System;

    public class Program
    {
        public static void Main(string[] args)
        {
            var count = Convert.ToInt32(Console.ReadLine());
            var friendList = new ushort[count, 2];
            var sumWidth = 0;
            ushort maxHeight = 0;
            ushort maxPreHeight = 0;
            var k = 0;
            for (var i = 0; i < count; i++)
            {
                var temp = Console.ReadLine().Split();
                friendList[i, 0] = ushort.Parse(temp[0]);
                friendList[i, 1] = ushort.Parse(temp[1]);
                sumWidth += friendList[i, 0];
                if (friendList[i, 1] > maxHeight)
                {
                    maxHeight = friendList[i, 1];
                    k = i;
                }

                if (friendList[i, 1] > maxPreHeight && friendList[i, 1] <= maxHeight && k != i)
                {
                    maxPreHeight = friendList[i, 1];
                }
            }

            var s = sumWidth * maxHeight;
            for (var i = 0; i < count; i++)
            {
                if (friendList[i, 1] != maxHeight)
                {
                    Console.Write((s - (friendList[i, 0] * maxHeight)) + " ");
                }
                else
                {
                    Console.Write((maxPreHeight * (sumWidth - friendList[i, 0])) + " ");
                }
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();
        var a = ReadIntMatrix(n);

        int max = -1, max2 = -1, s = 0;
        for (int i = 0; i < n; i++)
        {
            s += a[i][0];
            if (max == -1 || a[i][1] >= a[max][1])
            {
                max2 = max;
                max = i;
            }
            else if (max2 == -1 || a[i][1] > a[max2][1])
                max2 = i;
        }

        for (int i = 0; i < n; i++)
        {
            writer.Write((s - a[i][0]) * (i == max ? a[max2][1] : a[max][1]) + " ");
        }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("subsequences.in");
        //writer = new StreamWriter("subsequences.out");
#endif
        try
        {
//            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
//            thread.Start();
//            thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = Convert.ToInt32(Console.ReadLine());
            long[,] nn = new long[n, 2];
            long sum = 0;
            long max1 = 0;
            long max2 = 0;/*
            string[] str = Console.ReadLine().Split(' ');
            nn[0, 0] = Convert.ToInt32(str[0]);
            nn[0, 1] = Convert.ToInt32(str[1]);
            sum += nn[0, 0];
            max1 = nn[0, 1];
            str = Console.ReadLine().Split(' ');
            nn[1, 0] = Convert.ToInt32(str[0]);
            nn[1, 1] = Convert.ToInt32(str[1]);
            sum += nn[1, 0];
            max2 = nn[1, 1];
            if(max1 < max2)
            {
                long k = max1;
                max1 = max2;
                max2 = k;
            }*/
            for (int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                nn[i, 0] = Convert.ToInt32(str[0]);
                nn[i, 1] = Convert.ToInt32(str[1]);
                sum += nn[i, 0];
                if (max1 < nn[i, 1])
                {
                    max2 = max1;
                    max1 = nn[i, 1];
                }else
                    if (max2 < nn[i, 1])
                    {
                        max2 = nn[i, 1];
                    }
            }
            for (int i = 0; i < n; i++)
            {
                if (nn[i, 1] != max1)
                    Console.Write(((sum - nn[i, 0]) * max1).ToString() + ' ');
                else
                    Console.Write(((sum - nn[i, 0]) * max2).ToString() + ' ');
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = Convert.ToInt32(Console.ReadLine());
            long[,] nn = new long[n, 2];
            long sum = 0;
            long max1 = 0;
            long max2 = 0;
            string[] str = Console.ReadLine().Split(' ');
            nn[0, 0] = Convert.ToInt32(str[0]);
            nn[0, 1] = Convert.ToInt32(str[1]);
            sum += nn[0, 0];
            max1 = nn[0, 1];
            str = Console.ReadLine().Split(' ');
            nn[1, 0] = Convert.ToInt32(str[0]);
            nn[1, 1] = Convert.ToInt32(str[1]);
            sum += nn[1, 0];
            max2 = nn[1, 1];
            if(max1 < max2)
            {
                long k = max1;
                max1 = max2;
                max2 = k;
            }
            for (int i = 2; i < n; i++)
            {
                str = Console.ReadLine().Split(' ');
                nn[i, 0] = Convert.ToInt32(str[0]);
                nn[i, 1] = Convert.ToInt32(str[1]);
                sum += nn[i, 0];
                if (max1 <= nn[i, 1])
                {
                    max2 = max1;
                    max1 = nn[i, 1];
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (nn[i, 1] != max1)
                    Console.Write(((sum - nn[i, 0]) * max1).ToString() + ' ');
                else
                    Console.Write(((sum - nn[i, 0]) * max2).ToString() + ' ');
            }
        }
    }
}


using System;
using System.Data.SqlTypes;

namespace vkcup
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var widths = new int[n];

            var totalWidth = 0;

            var maxHeight = 0;
            var secondHeight = 0;

            var maxHeightIndex = -1;

            for (var i = 0; i < n; ++i)
            {
                var sz = Size.Parse(Console.ReadLine());

                totalWidth += sz.Width;
                widths[i] = sz.Width;

                if (maxHeight < sz.Height)
                {
                    secondHeight = maxHeight;
                    maxHeight = sz.Height;
                    maxHeightIndex = i;
                }
                else if (secondHeight < sz.Height)
                    secondHeight = sz.Height;
            }

            //

            for (var i = 0; i < n; ++i)
            {
                Console.Write((i == maxHeightIndex ? secondHeight : maxHeight) * (totalWidth - widths[i]) + " ");
            }
        }

        private struct Size : IEquatable<Size>
        {
            public int Height;
            public int Width;

            public Size(int w, int h)
            {
                Width = w;
                Height = h;
            }

            public static Size Parse(string str)
            {
                var arr = str.Split(' ');

                return new Size(int.Parse(arr[0]), int.Parse(arr[1]));
            }

            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj))
                    return false;

                return obj is Size && Equals((Size)obj);
            }

            public bool Equals(Size other)
            {
                return Height == other.Height && Width == other.Width;
            }

            public override int GetHashCode()
            {
                unchecked
                {
                    return (Height * 397) ^ Width;
                }
            }

            public static bool operator ==(Size left, Size right)
            {
                return left.Equals(right);
            }

            public static bool operator !=(Size left, Size right)
            {
                return !left.Equals(right);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace TaskBasic
{
    class Program
    {
        protected static TextReader reader;
        protected static TextWriter writer;

        public void Action()
        {
            int n = ReadInt();
            int max1 = 0;
            int max2 = 0;
            int width = 0;
            int[,] men = new int[n,2];
            int[] answers = new int[n];
            for (int i = 0; i < n; i++)
            {
                int[] man = ReadIntArray();
                men[i,0] = man[0];
                men[i,1] = man[1];
                width += man[0];
                if (man[1] > max1)
                {
                    max2 = max1;
                    max1 = man[1];
                }
                else
                {
                    if (man[1] <= max1)
                    {
                        if (man[1] > max2) {
                            max2 = man[1];
                        }
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                int curHeight = max1;
                int curWidth = width - men[i, 0];
                if (men[i, 1] == max1)
                {
                    curHeight = max2;

                }
                answers[i] = curHeight * curWidth;
            }
            WriteArray(answers);

        }
        static void Main(string[] args)
        {
            //reader = new StreamReader("..\\..\\input.txt");
            reader = new StreamReader(Console.OpenStandardInput());

            //writer = new StreamWriter("..\\..\\output.txt");
            writer = new StreamWriter(Console.OpenStandardOutput());

            new Program().Action();

            reader.Close();
            writer.Close();
        }

        private static Queue<string> currentLineTokens = new Queue<string>();
        private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
        public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
        public static int ReadInt() { return int.Parse(ReadToken()); }
        public static long ReadLong() { return long.Parse(ReadToken()); }
        public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
        public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
        public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
        public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
        public static void WriteArrayLines<T>(IEnumerable<T> array) { writer.WriteLine(string.Join("\n", array)); }
        public static void Write(params object[] array) { WriteArray(array); }
    }
}


using System;
using System.Collections.Generic;

namespace ФотоНаПамять
{
	class Program
	{
		struct Wh
		{
			public int W;
			public int H;
		}
		static void Main(string[] args)
		{
			int N = Convert.ToInt32(Console.ReadLine());
			List<Wh> list = new List<Wh>();
			long sumW = 0;
			int maxH1 = 0;
			int maxH2 = 0;
			string[] result;
			for (int i = 0; i < N; i++)
			{
				result = Console.ReadLine().Split();
				int w = Convert.ToInt32(result[0]);
				int h = Convert.ToInt32(result[1]);
				sumW += w;
				if (h > maxH1)
				{
					maxH2 = maxH1;
					maxH1 = h;
				}
				else
				{
					if (h > maxH2)
					{
						maxH2 = h;
					}
				}
				list.Add(new Wh { H = h, W = w });
			}
			for (int i = 0; i < list.Count; i++)
			{
				long sumWt = sumW - list[i].W;
				int maxHt = 0;
				if (maxH1 == list[i].H)
					maxHt = maxH2;
				else
					maxHt = maxH1;
				Console.Write((maxHt * sumWt) + " ");
			}
		}
	}
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Numerics;

namespace tes
{
	class contest
	{

		static void Main(string[] args)
		{

            int n = int.Parse(Console.ReadLine());
            var fr = new int[n][];

            var mxH = new List<int>();
            int sumW = 0;
            for(int i =0; i< n; i++)
            {
                fr[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                sumW += fr[i][0];
                mxH.Add(fr[i][1]);
            }

            mxH.Sort();
            var pix = new List<long>();
            for(int i =0; i< n; i++)
            {
                int w = fr[i][0];
                int h = fr[i][1];

                h = h == mxH.Last() ? mxH[n - 2] : mxH[n - 1];
                long dim = (sumW - w) * h;
                pix.Add(dim);
            }

            Console.WriteLine(string.Join(" ",pix));

        }

	}
}


using System;
using System.Linq;

namespace B
{
  class MainClass
  {
    public static void Main(string[] args)
    {
      int n, i, w, h, W = 0, max1 = 0, max1count = -1, max2 = -1, b;
      int[]
      size,
      widths,
      heights;

      n = int.Parse(Console.ReadLine());
      widths = new int[n];
      heights = new int[n];

      for (i = 0; i < n; ++i)
        {
          size = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
          W += size[0];
          widths[i] = size[0];
          heights[i] = size[1];

          if (heights[i] > max1)
            {
              max2 = max1;
              max1 = heights[i];
              max1count = 1;
            } else if (heights[i] == max1)
            {
              ++max1count;
            } else if (heights[i] > max2)
            {
              max2 = heights[i];
            }
        }

      for (i = 0; i < n; ++i)
        {
          w = widths[i];
          h = heights[i];
          if (h == max1)
            {
              if (max1count < 2)
                b = (W - w) * max2;
              else
                b = (W - w) * max1;
            } else
            {
              b = (W - w) * max1;
            }
          Console.Write(b);
          Console.Write(' ');
        }
      Console.WriteLine();
    }
  }
}


using System;
namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            string satan = "";
            int n = int.Parse(Console.ReadLine());
            int[] chir = new int[n];
            int[] vis = new int[n];
            string z = "0/0";
            int k = 0;
            int o = 0;
            int f = 0;
            for (int q = 0; q < n; q++)
            {
                string[] prop = Console.ReadLine().Split(' ');
                chir[q] = int.Parse(prop[0]);
                vis[q] = int.Parse(prop[1]);
                o += chir[q];

                if (vis[q] > k)
                {
                    if (vis[q] > int.Parse(z.Split('/')[0])) z = vis[q] + "/" + q;
                    else f = vis[q];
                    if (q == 0) k = 0;
                    else k = f;

                }
            }
            int h = 0;
            for (int t = 0; t < n; t++)//просчитывает всё n раз
            {
                if (int.Parse(z.Split('/')[1]) == t) h = k;
                else h = int.Parse(z.Split('/')[0]);
                if (t < n) satan += ((o - chir[t]) * h) + " ";
                else satan += ((o - chir[t]) * h);
            }
            Console.WriteLine(satan);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCUP2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] w = new int[100000];
            int[] t = new int[100000];
            string[] Input = new string[2];
            int h = 0;
            int z = 0;
            int z1 = 0;
            int z2 = 0;
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                Input = Console.ReadLine().Split(' ');
                w[i] = int.Parse(Input[0]);
                t[i] = int.Parse(Input[1]);
                if (int.Parse(Input[1]) > z)
                {
                    z = t[i];
                    z2 = i;
                }
                sum += w[i];
            }
            for (int i = 0; i < n; i++)
            {
                if (t[i] > z1)
                {
                    if (t[i] != z)
                    {
                        z1 = t[i];
                    }
                }
            }
            for (int l = 0; l < n; l++)
            {
                if (l == z2) h = z1;
                else h = z;

                if (l < n - 1) Console.Write(h * (sum - w[l]) + " ");
                else Console.WriteLine(h * (sum - w[l]));
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCUP2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] w = new int[100000];
            int[] t = new int[100000];
            string[] Input = new string[2];
            int h = 0;
            int z = 0;
            int z1 = 0;
            int z2 = 0;
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                Input = Console.ReadLine().Split(' ');
                w[i] = int.Parse(Input[0]);
                t[i] = int.Parse(Input[1]);
                if (t[i] > z)
                {
                    z = t[i];
                    z2 = i;
                }
                sum += w[i];
            }
            for (int i = 0; i < n; i++)
            {
                if (t[i] > z1)
                {
                    if (z2 != i)
                    {
                        z1 = t[i];
                    }
                }
            }
            for (int l = 0; l < n; l++)
            {
                if (l == z2) h = z1;
                else h = z;

                if (l < n - 1) Console.Write(h * (sum - w[l]) + " ");
                else Console.WriteLine(h * (sum - w[l]));
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCUP2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] w = new int[200000];
            int[] t = new int[200000];
            string[] Input = new string[2];
            int h = 0;
            int z = 0;
            int z1 = 0;
            int z2 = 0;
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                Input = Console.ReadLine().Split(' ');
                w[i] = int.Parse(Input[0]);
                t[i] = int.Parse(Input[1]);
                if (t[i] > z)
                {
                    z = t[i];
                    z2 = i;
                }
                sum += w[i];
            }
            for (int i = 0; i < n; i++)
            {
                if (t[i] > z1)
                {
                    if (z2 != i)
                    {
                        z1 = t[i];
                    }
                }
            }
            for (int l = 0; l < n; l++)
            {
                if (l == z2) h = z1;
                else h = z;

                if (l < n - 1) Console.Write(h * (sum - w[l]) + " ");
                else Console.WriteLine(h * (sum - w[l]));
            }
        }
    }
}


using System;
namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            string satan = "";
            int n = int.Parse(Console.ReadLine());
            int[] chir = new int[n];
            int[] vis = new int[n];
            for (int q = 0; q < n; q++)
            {
                string[] prop = Console.ReadLine().Split(' ');
                chir[q] = int.Parse(prop[0]);
                vis[q] = int.Parse(prop[1]);
            }
            for (int t = 0; t < n; t++)
            {
                int o = 0;
                int z = 0;
                for (int l = 0; l < n; l++)
                {
                    if (l != t)
                    {
                        o += chir[l];
                        if (vis[l] > z) z = vis[l];
                    }
                }
                if (t < n) satan += (o * z) + " ";
                else satan += (o * z);
            }
            Console.WriteLine(satan);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCUP2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] w = new int[100000];
            int h = 0;
            int z = 0;
            int z1 = 0;
            int z2 = 0;
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                string[] Input = Console.ReadLine().Split(' ');
                w[i] = int.Parse(Input[0]);
                if (int.Parse(Input[1]) > z)
                {
                    z = int.Parse(Input[1]);
                    z2 = i;
                }
                if (int.Parse(Input[1]) > z1)
                {
                    if (int.Parse(Input[1]) != z) z1 = int.Parse(Input[1]);
                }
                sum += w[i];
            }
            for (int l = 0; l < n; l++)
            {
                if (l == z2) h = z1;
                else h = z;

                if (l < n - 1) Console.Write(h * (sum - w[l]) + " ");
                else Console.WriteLine(h * (sum - w[l]));
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCupB
{
    class Program
    {
        public interface IReader
        {
            string GetNextLine();
        }

        public class ConsoleReader : IReader
        {
            public string GetNextLine()
            {
                return Console.ReadLine();
            }
        }

        public class Solver
        {
            private readonly IReader _reader;

            public Solver(IReader reader)
            {
                _reader = reader;
            }

            public struct TupleInt
            {
                public int SumWidth { get; private set; }
                public int MaxHeight { get; private set; }

                public void UpdateWidth(int width)
                {
                    SumWidth += width;
                }

                public void UpdateHeight(int value)
                {
                    if (MaxHeight == 0)
                    {
                        MaxHeight = value;
                    }
                    else
                    {
                        MaxHeight = Math.Max(MaxHeight, value);
                    }
                }
            }

            public void Solve()
            {
                int n = Convert.ToInt32(_reader.GetNextLine());

                Tuple<int, int>[] data = new Tuple<int, int>[n];
                TupleInt[] b = new TupleInt[n];

                for (int i = 0; i < n; i++)
                {
                    var inputData = _reader.GetNextLine().Split(' ');
                    data[i] = Tuple.Create(
                        Convert.ToInt32(inputData[0]),
                        Convert.ToInt32(inputData[1]));
                }

                int sumWidth = 0;
                int maxHeight = Int32.MinValue, maxHeightIndex = -1, prevMaxHeight = Int32.MinValue;

                for (int i = 0; i < n; i++)
                {
                    var cur = data[i];
                    sumWidth += cur.Item1;
                    if (maxHeight < cur.Item2)
                    {
                        maxHeight = cur.Item2;
                        maxHeightIndex = i;
                    }

                    if (i > 0 && i - 1 != maxHeightIndex)
                    {
                        prevMaxHeight = Math.Max(prevMaxHeight, data[i - 1].Item2);
                    }
                }

                for (int i = 0; i < n; i++)
                {
                    var cur = data[i];
                    int width = sumWidth - cur.Item1;
                    int height = cur.Item2 == maxHeight ? prevMaxHeight : maxHeight;

                    Console.Write(width * height);
                    if (i != n - 1)
                    {
                        Console.Write(' ');
                    }
                }
            }
        }

        static void Main(string[] args)
        {
            new Solver(new ConsoleReader()).Solve();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VKCupB
{
    class Program
    {
        public interface IReader
        {
            string GetNextLine();
        }

        public class ConsoleReader : IReader
        {
            public string GetNextLine()
            {
                return Console.ReadLine();
            }
        }

        public class Solver
        {
            private readonly IReader _reader;

            public Solver(IReader reader)
            {
                _reader = reader;
            }

            public struct TupleInt
            {
                public int SumWidth { get; private set; }
                public int MaxHeight { get; private set; }

                public void UpdateWidth(int width)
                {
                    SumWidth += width;
                }

                public void UpdateHeight(int value)
                {
                    if (MaxHeight == 0)
                    {
                        MaxHeight = value;
                    }
                    else
                    {
                        MaxHeight = Math.Max(MaxHeight, value);
                    }
                }
            }

            public void Solve()
            {
                int n = Convert.ToInt32(_reader.GetNextLine());

                Tuple<int, int>[] data = new Tuple<int, int>[n];
                TupleInt[] b = new TupleInt[n];

                for (int i = 0; i < n; i++)
                {
                    var inputData = _reader.GetNextLine().Split(' ');
                    data[i] = Tuple.Create(
                        Convert.ToInt32(inputData[0]),
                        Convert.ToInt32(inputData[1]));
                }

                int sumWidth = 0;
                int maxHeight = Int32.MinValue, maxHeightIndex = -1, prevMaxHeight = Int32.MinValue;

                for (int i = 0; i < n; i++)
                {
                    var cur = data[i];
                    sumWidth += cur.Item1;
                    if (maxHeight < cur.Item2)
                    {
                        maxHeight = cur.Item2;
                        maxHeightIndex = i;
                    }
                }

                for (int i = 0; i < n; i++)
                {
                    if (maxHeightIndex != i)
                    {
                        prevMaxHeight = Math.Max(prevMaxHeight, data[i].Item2);
                    }
                }

                for (int i = 0; i < n; i++)
                {
                    var cur = data[i];
                    int width = sumWidth - cur.Item1;
                    int height = cur.Item2 == maxHeight ? prevMaxHeight : maxHeight;

                    Console.Write(width * height);
                    if (i != n - 1)
                    {
                        Console.Write(' ');
                    }
                }
            }
        }

        static void Main(string[] args)
        {
            new Solver(new ConsoleReader()).Solve();
        }
    }
}