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

class Program
{
    public static void Main(string[] args)
    {
        //MulticaseTest();
        //int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = int.Parse(Console.ReadLine());
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (input.All(x => x >= 0)) Console.WriteLine(input.Sum());
        else
        {
            int C = input.Min();
            List<int> vals = input.ToList();
            vals.Remove(C);
            int val = vals.Sum() + Math.Abs(C);
            Console.WriteLine(val);
        }
    }

    public static void MulticaseTest()
    {
        //4
        //4 5 2 3
        int t = int.Parse(Console.ReadLine());
        List<string> o = new List<string>(t);
        for (int i = 0; i < t; i++)
        {
            int n = int.Parse(Console.ReadLine());

        }
        o.ForEach(Console.WriteLine);
    }
}


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

namespace _14._03._2018
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            short[] mas = new short[n];
            int B = 0;
            int C = 0;
            int MaxIntersection = 0;
            string[] temp = Console.ReadLine().Split();

            for (int i = 0; i<n; i++)
            {
                mas[i] = short.Parse(temp[i]);
                B += mas[i];
            }
            MaxIntersection = B;
            for (int i = n-1; i>=0; i--)
            {
                B -= mas[i];
                C += mas[i];
                if (B - C > MaxIntersection)
                    MaxIntersection = B - C;
            }
            Console.WriteLine(MaxIntersection);
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sleuth", "Sleuth\Sleuth.csproj", "{07CE28F7-8E8A-4E2B-BC41-0E80EED8755F}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{07CE28F7-8E8A-4E2B-BC41-0E80EED8755F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{07CE28F7-8E8A-4E2B-BC41-0E80EED8755F}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{07CE28F7-8E8A-4E2B-BC41-0E80EED8755F}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{07CE28F7-8E8A-4E2B-BC41-0E80EED8755F}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


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

namespace _49A
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            string y;
            char z;
            y = x.Remove(x.IndexOf('?'));
            if (y[y.Length-1]!=' ')
            {
                z = char.Parse(x.Substring(x.Length - 2, 1).ToLower());
            }
            else
            {
                z = char.Parse(x.Substring(x.Length - 3, 1).ToLower());
            }

            switch (z)
            {
                case 'a':
                    Console.WriteLine("YES");
                    break;
                case 'o':
                    Console.WriteLine("YES");
                    break;
                case 'y':
                    Console.WriteLine("YES");
                    break;
                case 'e':
                    Console.WriteLine("YES");
                    break;
                case 'u':
                    Console.WriteLine("YES");
                    break;
                case 'i':
                    Console.WriteLine("YES");
                    break;
                default:
                    Console.WriteLine("NO");
                    break;
            }
        }
    }
}


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

public class Task
{
	public static int SumAbs(IEnumerable<int> a)
	{
		var s = 0;
		var d = a.First();
		var t = 0;
		foreach (var i in a)
		{
			s += Math.Abs(i - d) * t;
			t = 1 - t;
			d = i;
		}
		return s;
	}

	public static Tuple<int, int> TwoRand(int max)
	{
		var r = new Random();
		var r1 = r.Next(max);
		var r2 = r.Next(max);
		while (r1 == r2)
		{
			r2 = r.Next(max);
		}
		return new Tuple<int, int>(r1, r2);
	}

	public static void Main()
	{
		#region Settings

		StreamReader In;
		StreamWriter Out;
		try
		{
			//System.Threading.Thread.CurrentThread.CurrentCulture =
			//	System.Globalization.CultureInfo.InvariantCulture;
		}
		finally
		{
#if file
			Directory.SetCurrentDirectory(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName);
			In = new StreamReader("input.txt");
			Out = new StreamWriter("output.txt");
#else
			In = new StreamReader(Console.OpenStandardInput());
			Out = new StreamWriter(Console.OpenStandardOutput());
#endif
		}

		#endregion

		var n = Int32.Parse(In.ReadLine());
		var s = In.ReadLine().Split();
		var a = (from i in s select Int32.Parse(i)).ToList();

		a.Sort();

		var mn = Int32.MaxValue;
		for (var i = 0; i < 5000000; i++)
		{
			var b = new List<int>(a);
			var r = TwoRand(b.Count);
			b.RemoveAt(Math.Max(r.Item1, r.Item2));
			b.RemoveAt(Math.Min(r.Item1, r.Item2));
			mn = Math.Min(mn, SumAbs(b));
		}

		Out.WriteLine(mn);

		//var mx = 0;
		//var r1 = 0;
		//var r2 = 0;
		//for (var i = 0; i < n * 2; i++)
		//{
		//	for (var j = 0; j < n * 2; j++)
		//	{
		//		if (mx < Math.Abs(a[i] - a[j]))
		//		{
		//			r1 = i;
		//			r2 = j;
		//			mx = Math.Abs(a[i] - a[j]);
		//		}
		//	}
		//}

		//a.RemoveAt(Math.Max(r1, r2));
		//a.RemoveAt(Math.Min(r1, r2));

		//var sum = 0;
		//for (var i = 0; i < a.Count - 3; i++)
		//{
		//	sum += Math.Abs(a[i + 1] - a[i]);
		//}

		//Out.WriteLine(sum);

		Out.Close();
	}
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2012 for Windows Desktop
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication8", "ConsoleApplication8\ConsoleApplication8.csproj", "{FD1BEE57-667E-4A93-A1F0-9A453E5F0534}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{FD1BEE57-667E-4A93-A1F0-9A453E5F0534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{FD1BEE57-667E-4A93-A1F0-9A453E5F0534}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{FD1BEE57-667E-4A93-A1F0-9A453E5F0534}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{FD1BEE57-667E-4A93-A1F0-9A453E5F0534}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


using System;

class Program
{
	static void Main()
	{
		int n = Convert.ToInt32(Console.ReadLine());
		string inp = Console.ReadLine();
		string[] par = inp.Split(' ');
		int i, d, prognoz;

		int[] a = new int[n];

		for (i = 0; i < n; i++)
			a[i] = Convert.ToInt32(par[i]);

		d = (a[n - 1] - a[0]) / (n - 1);
		if (d == a[1] - a[0])
			prognoz = a[n - 1] + d;
		else
			prognoz = a[n - 1];

		Console.WriteLine("{0}", prognoz);
	}
}


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

namespace CodeForces
{
    static class Reader
    {
        public static int NextInt()
        {
            int ret = 0;
            char c;

            while (!char.IsDigit(c = (char)Console.Read()))
            {
                if (c == '-')
                    return -NextInt();
            }
            do
            {
                ret = ret * 10 + c - '0';
            } while (char.IsDigit(c = (char)Console.Read()));

            return ret;
        }

        public static double NextDouble()
        {
            double ret = 0;
            char c;

            while (!char.IsDigit(c = (char)Console.Read()))
            {
                if (c == '-')
                    return -NextDouble();
            }
            do
            {
                ret = ret * 10 + c - '0';
            } while (char.IsDigit(c = (char)Console.Read()));
            if (c != '.') return ret;

            double p10 = 0.1;
            while (char.IsDigit(c = (char)Console.Read()))
            {
                ret += p10 * (c - '0');
            }

            return ret;
        }
    }

    class Program
    {
        static long[,] memo;
        static bool[,] done;

        static long Rec(int n, int h)
        {
            h = Math.Max(0, h);
            if (n <= 0 || (n == 1 && h <= 1))
                return 1;
            if (n < h)
                return 0;
            if (done[n, h])
                return memo[n, h];

            long ret = 0;
            for (int i = 1; i <= n; ++i)
                ret += Rec(i - 1, h - 1) * Rec(n - i, h - 1);
            done[n, h] = true;
            return memo[n, h] = ret;
        }

        static void Main(string[] args)
        {
            int n = Reader.NextInt(), h = Reader.NextInt();
            memo = new long[36, 36];
            done = new bool[36, 36];
            Console.WriteLine(Rec(n, h));
        }
    }
}


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

namespace A.Theatre_Square
{
    class Program
    {
        static int sq2(int k)
        {
            return (1 << k) - 1;
        }

        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Trim().Split(' ');
            int n = Int32.Parse(data[0]);
            int h = Int32.Parse(data[1]);
            Int64[,] f=new Int64[36,36];
            f[0, 0] = 1;
            f[1, 1] = 1;
            for (int i = 2; i <= n; i++)
            {
                for (int j = i; j <= n; j++)
                {
                    for (int k = 0; k <= j - 1; k++)
                    {
                        for (int l = (int)Math.Ceiling(Math.Log(k + 1, 2)); l <= k; l++)
                        {
                            for (int r = (int)Math.Ceiling(Math.Log(j - k, 2)); r <= j - k - 1; r++)
                            {
                                if(l==i-1 || r==i-1)
                                    f[i, j] += f[l, k] * f[r, j - k - 1];
                            }
                        }
                    }
                }
            }
            Int64 result = 0;
            for (int i = h; i <= n; i++)
            {
                result += f[i, n];
            }
            Console.WriteLine(result);
            Console.ReadKey();
        }
    }

}


using System;

namespace CodeForce
{
    public class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine();
            var answer = Solve(input1);
            Console.WriteLine(answer);
        }

        public static long Solve(string input)
        {
            var candies = long.Parse(input);
            var min = 1L;
            var k = Math.Max(candies / 2, 1);
            var top = k;
            while (top != min)
            {
                var moreThanHalf = VasyaEatsMoreThanHalf(candies, k);
                if (moreThanHalf)
                {
                    top = k;
                    k /= 2;
                }
                else
                {
                    k = (min + top) / 2;
                    min++;
                }
            }

            return min;
        }

        private static bool VasyaEatsMoreThanHalf(long candies, long k)
        {
            var totalCandies = candies;
            var vasya = 0L;
            while (candies > 0)
            {
                candies -= k;
                vasya += k;
                if (candies >= 10)
                {
                    var tenPercent = (long)(candies / 10);
                    candies -= tenPercent;
                }
                else
                {
                    vasya += candies;
                    candies = 0;
                }
            }

            return vasya >= Math.Ceiling(totalCandies / 2d);
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Int64 n = int.Parse(Console.ReadLine());
            bool res = true;
            int s = n;
            int temp = 0;
            while (s != 0)
            {
                temp = s % 10;
                if (temp != 7 && temp != 4)
                {
                    res = false;
                    break;
                }
                s /= 10;
            }
            if (res)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
         //   Console.ReadKey();
            //  Console.WriteLine(string.Join(", ", primeNumbers));
            // Console.ReadLine();
            //   var line = Console.ReadLine().Split(new[] { ' ' });

        }
    }
}


using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] rez = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int a = rez[1], b = rez[3];
            int check = (rez[3]>rez[1]?1:0) + (rez[4]<rez[2]?1:0);
            while(a!=rez[2]||b!=rez[4])
            {
                if (++a > rez[0]) a = 1;
                if (--b < 1) b = rez[0];
                if (a==b)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (--check>0&& b < a) break;
            }
            Console.WriteLine("NO");
        }
    }
}


using System;
using System.Linq;

namespace Codeforces
{
    public static class A
    {
        public static void Main()
        {
            var numbers = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = numbers[0];
            var a = numbers[1];
            var x = numbers[2];
            var b = numbers[3];
            var y = numbers[4];

            var pointA = a;
            var pointB = b;
            while (pointA != x || pointB != y)
            {
                if (pointA == pointB)
                {
                    Console.WriteLine("YES");
                    return;
                }

                if (pointA == n)
                {
                    pointA = 1;
                }
                else
                {
                    pointA++;
                }

                if (pointB == 1)
                {
                    pointB = n;
                }
                else
                {
                    pointB--;
                }
            }
            if (pointA == pointB)
            {
                Console.WriteLine("YES");
                return;
            }

            Console.WriteLine("NO");
        }
    }
}


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

namespace _LuckySum
{
    class ProgramLuckySum
    {
        static List<ulong> GetLuckyNumbers(int length)
        {
            var strNums = new List<string> {"4", "7"};
            while (strNums[strNums.Count - 1].Length < length)
            {
                var count = strNums.Count;
                for (var i=0; i<count; i++)
                {
                    strNums.Add(strNums[i] + "4");
                    strNums.Add(strNums[i] + "7");
                }
            }

            return strNums.Select(ulong.Parse).ToList();
        }

        static void Main(string[] args)
        {
            var luckyNumbers = GetLuckyNumbers(11);

            var input = Console.ReadLine();
            if (string.IsNullOrEmpty(input)) return;
            var lr = input.Split(' ');
            var l = ulong.Parse(lr[0]);
            var r = ulong.Parse(lr[1]);

            var i = 0;
            while (luckyNumbers[i] < l)
            {
                i++;
            }
            var sum = 0UL;
            var current = l;
            while (current <= r)
            {
                while (current <= luckyNumbers[i] && current <= r)
                {
                    sum += luckyNumbers[i];
                    current++;
                }
                i++;
            }

            Console.WriteLine(sum);
        }
    }
}


using System;

namespace Die_Roll
{

    class Program
    {

        static void Main(string[] args)
        {
            string[] RollChance = {"1/6","1/3", "1/2", "2/3", "5/6", "1/1"};
            string input = Console.ReadLine();
            byte y = byte.Parse(input.Split(' ')[0]);
            byte w = byte.Parse(input.Split(' ')[1]);
            byte max = Math.Max(y, w);
            Console.WriteLine(RollChance[max-2]);

        }
    }
}


using System;

public static class Solve {
    public static void main() {
        var s = Console.ReadLine().Split(" ");
        var lastLetter = s[1][0];
        Console.Write("{0", s[0][0]);
        for (int i = 1; i < s[0].Length; i++) {
            if (s[0][i] > lastLetter) break;
            Console.Write("{0}", s[0][i]);
        }
        Console.WriteLine("{0}", lastLetter);
    }
}


using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;

class P
{
    static void Main()
    {
        int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(3 * Min(abc[0] + 1, Min(abc[1], abc[2] - 1)));


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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            var ybr = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int y = ybr[0], b = ybr[1]-1, r = ybr[2]-2;
            Console.WriteLine(3*Math.Min(y,Math.Min(y,r))+3);
        }
    }
}


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

namespace ConsoleApplication34
{
    class Program
    {
        static void Main(string[] args)
        {
                int x = int.Parse(Console.ReadLine());
            char q = ' ', w = ' ', e = ' ';
            int u = 0;
                char[] a = new char[x];
                string s = Console.ReadLine();

                for (int i = 0; i < x; i++)
                {
                    a[i] = s[i];
                if (a[0] == '?' || a[x] == '?')
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (a[i] == '?')
                    {
                        w = a[i];
                        e = q;
                    }
                    if (a[i] != e && a[i] != '?' && q == '?' && e != '?')
                    {
                        u = 5;
                    }
                    if (a[i] == e && a[i] != '?' && q == '?' && e != '?')
                    {
                        Console.WriteLine("YES");
                        u = 0;
                        return;
                    }
                    if (q == a[i] && a[i] != '?')
                    {
                        Console.WriteLine("NO");
                        u = 5;
                        return;
                    }
                    q = a[i];
                }
                if (u == 0)
                    Console.WriteLine("YES");
                if (u == 5)
                    Console.WriteLine("NO");

        }
    }
}


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

class Startup
{
    static void Main()
    {
        int sizeCanvas = int.Parse(Console.ReadLine());
        string inputString = Console.ReadLine();

        bool result = false;
        char previous = inputString[0];
        char next = previous;

        if (sizeCanvas < 3 && inputString.IndexOf('?')!=-1)
        {
            result = true;
        }

        if (previous == '?' || inputString[sizeCanvas] =='?')
        {
            result = true;
        }

        for (int i = 1; i < sizeCanvas - 2; i++)
        {
            if (inputString[i] == '?' && ((previous == next) || (previous == '?')||(next=='?')))
            {
                result = true;
            }

            previous = inputString[i];
            next = inputString[i + 2];
        }

        if (result)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

    }
    public static List<int> ReadLineAndParseToList()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToList();
    }

    static int[] ReadLineAndParseToArray()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static int[,] TransposeMaxtrix(int[,] matrix)
    {
        int w = matrix.GetLength(0);
        int h = matrix.GetLength(1);

        int[,] result = new int[h, w];

        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
            {
                result[j, i] = matrix[i, j];
            }
        }
        return result;
    }
}


using System;

    class Program
    {
        static void Main()
        {
            string s = Console.ReadLine();
            int l = s.Length-1;
            ulong a = 0;
            for (int i = l; i >= 0; i--) {
                if (s[i] == '1') a = ((ulong)a + (ulong) Math.Pow(2, l - i)) % 1000000007;
            }
            a = (a * ((ulong)(Math.Pow(2, l) % 1000000007))) % 1000000007;
            Console.WriteLine(a);

        }
    }


using System;

public class Program{
    public static void Main(string[] args){
        string[] input = Console.ReadLine().Split(null);
        int k = Convert.ToInt32(input[0]);
        int a = Convert.ToInt32(input[1]);
        int b = Convert.ToInt32(input[2]);

        int a2 = a/k;
        int b2 = b/k;

        if(a2 == 0 && b2 == 0) Console.WriteLine(-1);
        else Console.WriteLine(a2+b2);

    }
}


using System;
using System.Collections.Generic;

namespace CodeForceCs
{
    static class Program
    {
        static void Main(string[] args)
        {
            Solver solver = new _Q910B();
            solver.SolveProblem();
            //Console.ReadKey();
        }
    }

    abstract class Solver
    {
        abstract public void SolveProblem();
    }

    class _Q910B : Solver
    {
        int n, a, b;
        List<int> need = new List<int>();
        override public void SolveProblem()
        {
            n = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            Console.WriteLine(GetResult());
        }

        int GetResult()
        {

            if (n >= 4 * a + 2 * b)
                return 1;

            if (n >= 2 * a + b)
                return 2;

            if (a >= b)
            {
                if (n >= 2 * a)
                    return 3;

                if (n >= a + b)
                    return 4;

                if (n >= 2 * b)
                    return 5;
            }
            else
            {
                if (n >= a + b)
                    return 3;

                if (n >= 2 * a)
                    return 4;
            }
            return 6;
        }
    }

}


using System;

namespace Обрамление_дверей
{
    class Program
    {
        static void Main(string[] args)
        {
            int barLength = int.Parse(Console.ReadLine());
            int borderLength = int.Parse(Console.ReadLine());
            int upperBorderLength = int.Parse(Console.ReadLine());

            int scrap, barNum = 0, aNum=0,bNum=0;

            while (true)
            {
                if (upperBorderLength <= borderLength && bNum < 2 || aNum >= 4 && bNum < 2)
                {
                    scrap = barLength;
                    barNum++;
                    scrap -= upperBorderLength;
                    bNum++;
                }
                else if(aNum<4 || bNum>=2 && aNum<4)
                {
                    scrap = barLength;
                    barNum++;
                    scrap -= borderLength;
                    aNum++;
                }
                else
                {
                    break;
                }
                while (true)
                {
                    int aTmp = scrap - borderLength;
                    int bTmp = scrap - upperBorderLength;
                    if (aTmp>=0&&aTmp<=bTmp&&aNum<4 || aTmp>=0&&aNum<4&&bNum>=2)
                    {
                        scrap = aTmp;
                        aNum++;
                    }
                    else if (bTmp>=0&&bNum<2 || bTmp >= 0 && bNum < 2 && aNum >= 4)
                    {
                        scrap = bTmp;
                        bNum++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Console.WriteLine(barNum);
        }
    }
}


using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = Convert.ToByte(Console.ReadLine());
            long lastEvenPosition, lastOddPosition, evenSum, oddSum;

            if (n % 2 == 0)
            {
                lastEvenPosition = n / 2;
                lastOddPosition = n / 2;
            }
            else
            {
                lastOddPosition = (n + 1) / 2;
                lastEvenPosition = (n - 1) / 2;
            }

            evenSum = lastEvenPosition * lastEvenPosition + lastEvenPosition;
            oddSum = lastOddPosition * lastOddPosition;
            Console.WriteLine(evenSum - oddSum);
        }
    }
}


using System;

namespace Contest
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				string s = Console.ReadLine();
				string[] d = s.Split(' ');
				long n = long.Parse(d[0]);
				int k = int.Parse(d[1]);
				int div = (int)Math.Pow(10, k);
				long nn = n;
				while (n % div != 0)
				{
					n += nn;
				}

				Console.WriteLine(n);
			}
		}
	}
}


using System;

namespace CodeForces
{
	class A
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] d = s.Split(' ');
			long n = long.Parse(d[0]);
			int k = int.Parse(d[1]);
			int div = (int)Math.Pow(10, k);
			long nn = n;

			while (n % div != 0)
			{
				n += nn;
			}

			Console.WriteLine(n);
		}
	}
}


using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double result = 0;
            var maxValueOfElement = double.Parse(args[0]);
            var desiredSum = double.Parse(args[1]);
            result = Math.Ceiling(desiredSum / maxValueOfElement);
            Console.WriteLine(result);
        }
    }
}


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

namespace skobka
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] numbers = Console.ReadLine().Split(' ');
            int countnumb = int.Parse(numbers[0]);
            int sum = int.Parse(numbers[1]);
            List<int> list = new List<int>();
            int count = 0;
            for (int i = 0; i < countnumb; i++)
            {
                list.Add(i + 1);
            }
            int j = countnumb - 1;
            while (sum > 0)
            {
                if (list[j] <= sum)
                {
                    sum -= list[j];
                    count++;
                }
                else
                    j--;
            }
            Console.WriteLine(count);
            //Console.ReadKey();
        }
    }
}


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

namespace ConsoleApplication57
{
    class Program
    {
        static void Main(string[] args)
        {
            long a, b;
            string[] input = Console.ReadLine().Split(' ');
            a = Int64.Parse(input[0]);
            b = Int64.Parse(input[1]);
            long count = 0;
            for (long i = b + 1; i <= a - b; i++)
            {
                if ((a - b) % i == 0) count++;
            }
            if (a != b) Console.WriteLine(count);
            else Console.WriteLine("infinity");
            //Console.ReadLine();
        }
    }
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();
            var a = data[0];
            var b = data[1];
            r = a - b;

            if (a == b)
            {
                Console.WriteLine("infinity");
                return;
            }
            else if (a < b)
            {
                Console.WriteLine(0);
                return;
            }
            else
            {
                //var n = (int)Math.Ceiling(Math.Sqrt(r));
                var counter = 0;
                for (int i = 1; i <= r; i++)
                {
                    var rem = r % i;
                    if (rem == 0 && i > b)
                    {
                        counter++;
                    }
                }

                Console.WriteLine(counter);
                return;
            }

            //var dels = new int[10];
            //var v2 = (getT(2) + 1);
            //var v3 = (getT(3) + 1);
            //var v5 = (getT(5) + 1);
            //var v7 = (getT(7) + 1);
            //var f2 = v2 - getT(b, 2);
            //var f3 = v3 - getT(b, 3);
            //var f5 = v5 - getT(b, 5);
            //var f7 = v7 - getT(b, 7);

            //var res = f2 * f3 * f5 * f7;
            //Console.WriteLine(res);
        }

        static int r;
        static int getT(int del)
        {
            //var r = r1;
            if (r % del == 0)
            {
                int pos = 0;
                while (true)
                {
                    var rem = r % del;

                    if (rem == 0)
                    {
                        pos++;
                        r = r / del;
                    }
                    else
                    {
                        break;
                    }
                }

                return pos;
            }
            else
            {
                return 0;
            }
        }

        static int getT(int del, int r2)
        {
            //var r = r1;
            if (r2 % del == 0)
            {
                int pos = 0;
                while (true)
                {
                    var rem = r2 % del;

                    if (rem == 0)
                    {
                        pos++;
                        r2 = r2 / del;
                    }
                    else
                    {
                        break;
                    }
                }

                return pos;
            }
            else
            {
                return 0;
            }
        }
    }
}


using System;
using CompLib.Util;

public class Program
{
    int N, M;
    int[] A;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        A = sc.IntArray();

        /*
         * n個カップ
         * i個目にはa[i]カフェイン
         *
         * i日にk個 (a_1,a_2...a_k)を飲む
         *
         * 1杯目 a_1
         * 2    a_2 -1
         * n    a_n - (n-1)
         *
         * mを終わらせるために何日必要か?
         */

        long sum = 0;
        foreach (int l in A)
        {
            sum += l;
        }

        // n日で終わらせる
        //
        if (sum < M)
        {
            return;
        }

        Array.Sort(A, (l, r) => r.CompareTo(l));
        int ng = 0;
        int ok = N;
        while (ok - ng > 1)
        {
            int mid = (ok + ng) / 2;
            // mid日で終わらせられるか?
            if (C(mid)) ok = mid;
            else ng = mid;
        }

        Console.WriteLine(ok);
    }

    bool C(int d)
    {
        // dを分散

        long s = 0;
        for (int i = 0; i < N; i++)
        {
            long l = i / d;
            s += Math.Max(0, A[i] - i / d);
        }

        return s >= M;
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

namespace cf1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader("in.txt"));
            string str = Console.ReadLine();
            string[] s = str.Split(' ');
            int n = Convert.ToInt32(s[0]);
            int k = Convert.ToInt32(s[1]);
            int sum=0;
            str = Console.ReadLine();
            s = str.Split(' ');

            for (int i = 0; i < n; i++)
                sum += Convert.ToInt32(s[i]);
            double a = sum / (double)n;
            if (a > k - 0.5)
                Console.WriteLine("0");
            else
            {
                double f = 2 * (k * n - 0.5 * n - sum);
                Console.WriteLine(Convert.ToInt32(f));
            }
            Console.ReadKey();

        }
    }
}


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{278E3467-7E64-46DE-AC00-08AC85518C02}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>CodeForces</RootNamespace>
    <AssemblyName>CodeForces</AssemblyName>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkSubset>
    </TargetFrameworkSubset>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data.DataSetExtensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


using System;
using System.IO;
using System.Collections.Generic;
namespace C_
{
    class Program
    {
        static void Main(string[] args)
        {

            int x = Convert.ToInt32(Console.ReadLine());
            int[] home = new int[x];
            int[] gest = new int[x];
            for (int i = 0; i < x; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                home[i] = Convert.ToInt32(s[0]);
                gest[i] = Convert.ToInt32(s[1]);
            }
            int count = 0;
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (home[i] == gest[j] && i != j)
                    {
                        count++;
                        Console.WriteLine(count);
                    }
                }
            }
        }
    }
}


using System;
using System.Linq;
namespace _887B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[][] a = new int[n][];
            for (int i = 0; i < n; i++)
                a[i] = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            bool[] canBuild = new bool[1005];
            for (int i = 0; i < 1000; i++)
            {
                if (i < 10)
                {
                    for (int j = 0; j < 3; j++)
                        canBuild[i] |= a[j].Contains(i);
                }
                else if (i >= 10 && i < 100)
                {
                    if (n < 2)
                        continue;
                    for (int j = 0; j < 3; j++)
                        for (int k = 0; k < 3; k++)
                        {
                            if (j == k)
                                continue;
                            canBuild[i] |= a[j].Contains(i / 10) && a[k].Contains(i % 10);
                        }
                }
                else
                {
                    if (n < 3)
                        continue;
                    for (int j = 0; j < 3; j++)
                        for (int k = 0; k < 3; k++)
                        {
                            if (j == k)
                                continue;
                            for (int l = 0; l < 3; l++)
                            {
                                if (j == l || k == l)
                                    continue;
                                canBuild[i] |= a[j].Contains(i / 100) && a[k].Contains((i / 10) % 10) &&
                                               a[l].Contains(i % 10);
                            }
                        }
                }
            }
            int result = 0;
            for (int i = 1; i < 1000; i++)
            {
                bool res = true;
                for (int j = 1; j <= i; j++)
                    res &= canBuild[j];
                if (res)
                    result = Math.Max(result, i);
            }
            Console.WriteLine(result);
        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 0;
            int noOfCubes = int.Parse(Console.ReadLine());
            List<int[]> cubes = new List<int[]>();
            int[] digits = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            for (int i = 0; i < noOfCubes; i++)
            {
                var a = Console.ReadLine().Split(' ');
                int[] cube = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                foreach (var d in a)
                {
                    var j = 0;
                    int.TryParse(d, out j);
                    cube[j] = 1;
                }
                for (int j = 0; i < 10; j++)
                {
                    digits[j] += cube[j];
                }
                cubes.Add(cube);
            }

            for (int i = 1; i <= noOfCubes; i++)
            {
                for (int j = 0; j < digits.Length; j++)
                {
                    if (j == 0 && digits[j] < (i - 1))
                    {
                        var abc = Math.Pow(10, i - 1) - 1;
                        Console.WriteLine(abc);
                        return;
                    }
                    else if (j != 0 && digits[j] < i)
                    {
                        string result = "";
                        var oCubes = cubes.FindAll(c => c[j] == 0);
                        int[] abc = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                        foreach (var c in oCubes)
                        {
                            for (int z = 0; z < 10; z++)
                            {
                                abc[z] += c[z];
                            }
                        }
                        for (int m = 0; m < 10; m++)
                        {
                            if (abc[m] == 0)
                            {
                                for (int n = 0; n < i - 1; n++)
                                {
                                    result += j.ToString();
                                }
                                if (m != 0)
                                {
                                    result += (m - 1).ToString();
                                    Console.WriteLine(int.Parse(result));
                                    return;
                                }
                                else if (m == 0 && i > 1)
                                {
                                    result += "0";
                                    Console.WriteLine(int.Parse(result) - 1);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine(x);
        }
    }
}


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

namespace ConsoleApplication16
{
    class Program
    {
        static void Main(string[] args)
        {
            int x1 = 0; int y1 = 0;
            string[] temp = Console.ReadLine().Split(' ');
            int x2 = int.Parse(temp[0]);
            int y2 = int.Parse(temp[1]);
            int s = int.Parse(temp[2]);
            int s0 = 0;
            while ((x1 != x2) || (y1 != y2))
            {
                if (x1 < x2)
                {
                    x1 = x1 + 1;
                    s0++;
                }
                else
                if (x1 > x2)
                {
                    x1 = x1 - 1;
                    s0++;
                }
                if (y1 < y2)
                {
                    y1 = y1 + 1;
                    s0++;
                }
                else
                if (y1 > y2)
                {
                    y1 = y1 + 1;
                    s0++;
                }
            }
            if ((s0 % 2 == s % 2) && (s>=s0))
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//неправильный ответ на тесте 12
namespace F
{
    class Program
    {
        class tree
        {
            public long ves;
            public int nn;//индек первого элемента
            public int nk;//индек последнего элемента
            public tree l;
            public tree r;
            public tree p;
            public tree(int[] m, int i1, int ik, tree p1)
            {
                if (i1 == ik)
                {
                    nn = i1;
                    nk = ik;
                    l = null;
                    r = null;
                    ves = m[i1];
                    wt[i1] = this;
                }
                else
                {
                    int s = (ik + i1 + 1) / 2/*+ (ik - i1) % 2*/;
                    nn = i1;
                    nk = ik;
                    l = new tree(m, i1, s - 1, this);
                    r = new tree(m, s, ik, this);
                    ves = l.ves + r.ves;
                }
                p = p1;
            }

        }
        static long FindVes(tree t1, tree tn)
        {
            long ves = 0;
            int x1 = t1.nn;
            int y1 = tn.nk;
            if (y1 < x1) return 0;
            tree ti = wt[x1];
            while (ti.nk < y1) ti = ti.p;
            ves = (long)ti.ves;
            tree tiv = ti;
            while (ti.nn < x1)
            {
                if (ti.r.nn <= x1)
                {
                    ves = ves - (long)ti.l.ves;
                    ti = ti.r;
                }
                else
                {
                    ti = ti.l;
                }
            }
            ti = tiv;
            while (ti.nk > y1)
            {
                if (ti.l.nk >= y1)
                {
                    ves = ves - (long)ti.r.ves;
                    ti = ti.l;
                }
                else
                {
                    ti = ti.r;
                }
            }
            return ves;
        }
        static tree[] wt;
        static void Main(string[] args)
        {
            TextReader sr = Console.In;
            //StreamReader sr = new StreamReader("in7.txt");
            string[] s = sr.ReadLine().Split();
            int n = Convert.ToInt32(s[0]);
            int q = Convert.ToInt32(s[1]);
            s = sr.ReadLine().Split();
            string[] s1 = sr.ReadLine().Split();
            int[] a = new int[n];
            int[] w = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
                w[i] = Convert.ToInt32(s1[i]);
            }
            //решение
            wt = new tree[n];
            tree t1 = new tree(w, 0, n - 1, null);
            int x, y;
            tree ti;
            List<int> res = new List<int>();
            for (int i = 0; i < q; i++)
            {
                s = sr.ReadLine().Split();
                x = Convert.ToInt32(s[0]);
                y = Convert.ToInt32(s[1]);
                if (x < 0)
                {
                    int delta = y - w[-1 - x];
                    w[-1 - x] = y;
                    ti = wt[-1 - x];
                    while (ti != null)
                    {
                        ti.ves = ti.ves + delta;
                        ti = ti.p;
                    }
                }
                else
                {
                    if (x == y)
                    {
                        res.Add(0);
                    }
                    else if ((y - x) == (a[y - 1] - a[x - 1]))
                    {
                        res.Add(0);
                    }
                    else if ((y - x) == 1)
                    {
                        if (w[x-1] > w[y-1])
                        {
                            res.Add((int)(((long)(a[y-1]- a[x - 1] - 1)* (long)w[y - 1])% (long)(1000000007)));
                        }
                        else
                        {
                            res.Add((int)(((long)(a[y - 1] - a[x - 1] - 1) * (long)w[x - 1]) % (long)(1000000007)));
                        }
                    }
                    else
                    {
                        //найти вес отрезка
                        int x1 = x - 1;
                        int y1 = y - 1;
                        long ves = FindVes(wt[x1], wt[y1]);
                        long vl, vr,vv;
                        int iis, iiss;
                        int iisll=x1, iislr=y1;
                        iis = (x1 + y1 + 1) / 2;
                        vl = FindVes(wt[x1], wt[iis - 1]);
                        vr = FindVes(wt[iis + 1],wt[y1] );
                        while (true)
                        {
                            if ((vl + w[iis] > vr) && (vr + w[iis] > vl)) break;
                            if (vl + w[iis] == vr) {
                                if (w[iis] >= w[iis + 1]) break;
                                else
                                {
                                    iis++;
                                    break;
                                }
                            }
                            if (vr + w[iis] == vl)
                            {
                                if (w[iis] >= w[iis - 1]) break;
                                else
                                {
                                    iis--;
                                    break;
                                }
                            }
                            if ((vl + w[iis]) >(vr + w[iis]))
                            {
                                iiss = (iisll + iis) / 2;
                                vv= FindVes(wt[iiss + 1], wt[iis- 1]);
                                vl =vl-vv- w[iiss];
                                vr =vr+vv+ w[iis];
                                iislr = iis;
                                iis = iiss;
                            }
                            else
                            {
                                iiss = (iislr + iis + 1) / 2;
                                vv = FindVes(wt[iis + 1], wt[iiss - 1]);
                                vl = vl + vv + w[iis];
                                vr = vr - vv - w[iiss];
                                iisll = iis;
                                iis = iiss;
                            }
                        }
                        long r = 0;
                        for (int j = x1; j < iis; j++)
                        {
                            r = (r + ((long)w[j] * (long)(a[iis] - a[j] - (iis-j)))) % 1000000007;
                        }
                        for (int j = iis+1; j <=y1; j++)
                        {
                            r = (r + ((long)w[j] * (long)(a[j] - a[iis] - (j-iis)))) % 1000000007;
                        }
                        res.Add((int)r);
                    }
                }
            }
            Console.WriteLine(string.Join("\n", res));
        }
    }
}


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

namespace F
{
    class Program
    {
        static Tree[] wt;
        class Tree
        {
            public long ves;
            public long ves_;
            public int nn;//индек первого элемента
            public int nk;//индек последнего элемента
            public Tree l;
            public Tree r;
            public Tree p;
            public Tree(int[] m, int[] a, int i1, int ik, Tree p1)
            {
                nn = i1;
                nk = ik;
                if (i1 == ik)
                {
                    l = null;
                    r = null;
                    ves = m[i1];
                    ves_ = ((long)(a[i1] - i1) * (long)m[i1]) % (long)(1000000007);
                    wt[i1] = this;
                }
                else
                {
                    int s = (ik + i1 + 1) / 2;
                    l = new Tree(m, a, i1, s - 1, this);
                    r = new Tree(m, a, s, ik, this);
                    ves = l.ves + r.ves;
                    ves_ = (l.ves_ + r.ves_) % (long)(1000000007);
                }
                p = p1;
            }
        }

        static long FindVes(Tree t1, Tree tn, bool t)//t=true ves;t=false ves_;
        {
            long ves = 0;
            int x1 = t1.nn;
            int y1 = tn.nk;
            if (y1 < x1) return 0;
            Tree ti = wt[x1];
            long sub = 0;
            while (ti.nk < y1)
            {
                if (ti.p.r == ti)
                {
                    if (t) sub = sub + ti.l.ves;
                    else sub = (sub + ti.l.ves_) % (long)(1000000007);
                }
                ti = ti.p;
            }
            if (t) ves = (long)ti.ves;
            else ves = (long)ti.ves_;
            if (t) ves =ves-sub;
            else ves =(ves-sub+ +(long)(1000000007)) % (long)(1000000007);
            //Tree tiv = ti;
            //while (ti.nn < x1)
            //{
            //    if (ti.r.nn <= x1)
            //    {
            //        if (t) ves = ves - (long)ti.l.ves;
            //        else ves = (ves - (long)ti.l.ves_ + (long)(1000000007)) % (long)(1000000007);
            //        ti = ti.r;
            //    }
            //    else
            //    {
            //        ti = ti.l;
            //    }
            //}
            //ti = tiv;
            while (ti.nk > y1)
            {
                if (ti.l.nk >= y1)
                {
                    if (t) ves = ves - (long)ti.r.ves;
                    else ves = (ves - (long)ti.r.ves_ + (long)(1000000007)) % (long)(1000000007);
                    ti = ti.l;
                }
                else
                {
                    ti = ti.r;
                }
            }
            return ves;
        }

        static void Main(string[] args)
        {
            TextReader sr = Console.In;
            //StreamReader sr = new StreamReader("in1.txt");
            string[] s = sr.ReadLine().Split();
            int n = Convert.ToInt32(s[0]);
            int q = Convert.ToInt32(s[1]);
            s = sr.ReadLine().Split();
            string[] s1 = sr.ReadLine().Split();
            int[] a = new int[n];
            int[] w = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
                w[i] = Convert.ToInt32(s1[i]);
            }
            //решение
            wt = new Tree[n];
            Tree t1 = new Tree(w, a, 0, n - 1, null);

            int ll;
            int rr;
            int id, nw;
            bool zapros1;
            Tree ti;
            List<int> res = new List<int>();
            for (int i = 0; i < q; i++)
            {
                s = sr.ReadLine().Split();
                ll = Convert.ToInt32(s[0]);
                if (ll < 0) zapros1 = true; else zapros1 = false;
                id = -1 - ll;
                ll--;
                nw = Convert.ToInt32(s[1]);
                rr = nw - 1;
                if (zapros1)
                {
                    ti = wt[id];
                    long delta = (long)nw - ti.ves;
                    long delta_ = (((long)(a[id] - id) * (long)nw)) % (long)(1000000007) - ti.ves_;
                    w[id] = nw;
                    while (ti != null)
                    {
                        ti.ves = ti.ves + delta;
                        ti.ves_ = (ti.ves_ + delta_ + (long)(1000000007)) % (long)(1000000007);
                        ti = ti.p;
                    }
                }
                else
                {
                    if (ll == rr)
                    {
                        res.Add(0);
                    }
                    else if ((rr - ll) == (a[rr] - a[ll]))
                    {
                        res.Add(0);
                    }
                    else if ((rr - ll) == 1)
                    {
                        if (w[ll] > w[rr])
                        {
                            res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[rr]) % (long)(1000000007)));
                        }
                        else
                        {
                            res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[ll]) % (long)(1000000007)));
                        }
                    }
                    else
                    {
                        //найти вес отрезка
                        long ves = FindVes(wt[ll], wt[rr], true);
                        long vl, vr, vv;
                        int iis, iiss;
                        int iisll = ll, iislr = rr;
                        iis = (ll + rr + 1) / 2;
                        vl = FindVes(wt[ll], wt[iis - 1], true);
                        vr = FindVes(wt[iis + 1], wt[rr], true);
                        while (true)
                        {
                            if ((vl + w[iis] > vr) && (vr + w[iis] > vl)) break;
                            if (vl + w[iis] == vr)
                            {
                                if (w[iis] < w[iis + 1]) iis++;
                                break;
                            }
                            if (vr + w[iis] == vl)
                            {
                                if (w[iis] < w[iis - 1]) iis--;
                                break;
                            }
                            if ((vl) > (vr))
                            {
                                iiss = (iisll + iis) / 2;
                                vv = FindVes(wt[iiss + 1], wt[iis - 1], true);
                                vl = vl - vv - w[iiss];
                                vr = vr + vv + w[iis];
                                iislr = iis;
                                iis = iiss;
                            }
                            else
                            {
                                iiss = (iislr + iis + 1) / 2;
                                vv = FindVes(wt[iis + 1], wt[iiss - 1], true);
                                vl = vl + vv + w[iis];
                                vr = vr - vv - w[iiss];
                                iisll = iis;
                                iis = iiss;
                            }
                        }
                        long r = 0;
                        if (iis > ll)
                        {
                            r = (r - (FindVes(wt[ll], wt[iis - 1], false) % (long)(1000000007)) + (long)(1000000007)) % (long)(1000000007);
                            r = (r + (long)(a[iis] - iis) * (FindVes(wt[ll], wt[iis - 1], true) % (long)(1000000007))) % (long)(1000000007);

                        }
                        if (iis < rr)
                        {
                            r = (r + (FindVes(wt[iis + 1], wt[rr], false)) % (long)(1000000007)) % (long)(1000000007);
                            r = (r - (long)(a[iis] - iis) * (FindVes(wt[iis + 1], wt[rr], true) % (long)(1000000007)) % (long)(1000000007) + (long)(1000000007)) % (long)(1000000007);
                        }
                        res.Add((int)r);
                    }
                }
            }
            Console.WriteLine(string.Join("\n", res));
        }
    }
}


using System;

namespace MyTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split();
            string[] input2 = Console.ReadLine().Split();
            int x1 = Convert.ToInt16(input1[0]);
            int y1 = Convert.ToInt16(input1[1]);
            int x2 = Convert.ToInt16(input2[0]);
            int y2 = Convert.ToInt16(input2[1]);
            int d = 0;
            while (x1 != x2 || y1 != y2)
            {
                if (x1 > x2 && y1 > y2)
                {
                    x1--;
                    y1--;
                }
                else if (x1 < x2 && y1 < y2)
                {
                    x1++;
                    y1++;
                }
                else if (x1 < x2 && y1 > y2)
                {
                    x1++;
                    y1--;
                }
                else if (x1 > x2 && y1 < y2)
                {
                    x1--;
                    y1++;
                }
                else if (x1 > x2 && y1 == y2)
                {
                    x1--;
                }
                else if (x1 < x2 && y1 == y2)
                {
                    x1++;
                }
                else if (x1 == x2 && y1 > y2)
                {
                    y1--;
                }
                else if (x1 == x2 && y1 < y2)
                {
                    y1++;
                }
                d++;
            }
            Console.WriteLine("{0}", d);
        }
    }
}


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

namespace Contest
{
    class Program
    {
        static void SetInput()
        {
            var textReader = new StreamReader("input.txt");
            Console.SetIn(textReader);
        }

        static IEnumerable<T> Parse<T>(string line, Func<string, T> converter)
        {
            return line.Split(' ').Select(converter);
        }

        static IEnumerable<int> ReadInts()
        {
            return ReadLine(x => int.Parse(x));
        }

        static IEnumerable<long> ReadLongs()
        {
            return ReadLine(x => long.Parse(x));
        }

        static IEnumerable<double> ReadDoubles()
        {
            return ReadLine(x => double.Parse(x));
        }

        static IEnumerable<T> ReadLine<T>(Func<string, T> converter)
        {
            var line = Console.ReadLine();

            return Parse(line, converter);
        }

        static void Print<T>(IEnumerable<T> values)
        {
            Console.WriteLine(string.Join(" ", values));
        }

        static void Main(string[] args)
        {
            SetInput();
            var start = ReadLongs().ToArray();
            var finish = ReadLongs().ToArray();

            Console.WriteLine(Math.Max(Math.Abs(start[0] - finish[1]), Math.Abs(start[1] - finish[1])));
        }
    }
}


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

namespace ConsoleApplication5
{
    class Program
    {

        static void Main(string[] args)
        {
            string simple = "31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";
           string s = Console.ReadLine();
            if(simple.Contains(s))
                Console.WriteLine("YES");
            else Console.WriteLine("NO");
            Main(null);
        }

    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{

    static bool IsPossible(int[] months, int[] data)
    {
        var idxs = data.Select((s, i) => s == months[0] ? i : -1).Where(s => s >= 0);
        foreach (var idx in idxs)
        {
            var found = true;
            for (var i = 0; i < months.Length; i++)
            {
                if (months[i] != data[(idx + i) % data.Length])
                {
                    found = false;
                    break;
                }
            }
            if (found)
                return true;
        }
        return false;
    }

    static void Main(String[] args)
    {
        var leap = new[] {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        var nonLeap = new[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

        var leapAndNonLeap = new int[24];
        leap.CopyTo(leapAndNonLeap, 0);
        nonLeap.CopyTo(leapAndNonLeap, 12);

        var leapLeap = new int[24];
        leap.CopyTo(leapLeap, 0);
        leap.CopyTo(leapLeap, 12);

        var n = Convert.ToInt32(Console.ReadLine());
        var tempA = Console.ReadLine().Split(' ');
        var months = Array.ConvertAll(tempA, int.Parse);

        var possible = IsPossible(months, leapAndNonLeap) || IsPossible(months, leapLeap);
        Console.WriteLine("{0}", possible ? "YES" : "NO");
        Console.ReadLine();
    }
}


using System;

namespace _4A
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var b = new bool[10];
            for (int i = 0; i < str.Length; i++)
            {
                b[int.Parse(str[i])] = true;
            }

            int counter = 0;
            for (int i = 0; i < b.Length; i++)
            {
                if (b[i]) counter++;
            }

            Console.WriteLine(str.Length - counter);
        }
    }
}


using System;

namespace ConsoleApp20
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var m = int.Parse(Console.ReadLine());
            if(n>=30){Console.Write(m); return;}
            Console.WriteLine(m%(1>>n));
        }
    }
}


using System;
 class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.In.ReadToEnd().Split(new char[] { ' ', '\t', '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries);
            int k = int.Parse(input[1]);
            input[0] = input[1] = null;
            bool[] db = new bool[27];
            int res = 0;
            for (int i = 0; i < input[2].Length; i++)
                db[input[2][i]] = true;
            for(int i = 1; k>0;)
            {
                for(; i<db.Length; ++i)
                {
                    if(db[i])
                    {
                        --k;
                        res += i;
                        i += 2;
                        break;
                    }
                }
            }
            Console.WriteLine(k > 0 ? -1 : res);
        }
    }


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

namespace ConsoleApp13
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            string input = Console.ReadLine();
            n = int.Parse(input.Split(' ')[0]);
            k = int.Parse(input.Split(' ')[1]);
            input = Console.ReadLine();
            int[] arr = new int[26];
            for (int i = 0; i < n; i++)
            {
                arr[int.Parse(input[i].ToString())]++;
            }

            int ot = 0, sum = 0;
            for (int i = 0; i < 26; i++)
            {
                if (ot > 0)
                {
                    ot--;
                    continue;
                }
                if (int.Parse(arr[i].ToString()) != 0)
                {
                    k--;
                    sum += arr[i] - 'a' + 1;
                    ot += 1;
                }
                if (k == 0) break;
            }
            if (k > 0) Console.WriteLine(-1);
            else
            {
                Console.WriteLine(sum);
            }
        }
    }
}


#region License

// Copyright (C) 2012 Kazunori Sakamoto
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#endregion

using System;
using System.IO;

namespace Codeforces {
	public class ProblemE {
		//public static void Main(string[] args) {
		//    new ProblemE().Solve(Console.In);
		//}

		private void Solve(TextReader input) {
			//1:  0,  1
			//2:  3,  2 = 1 * 3, 0 + 1 * 2
			//3:  6,  7 = 2 * 3, 3 + 2 * 2
			//4: 21, 20 = 7 * 3, 6 + 7 * 2
			var n = int.Parse(input.ReadLine()) - 1;
			var d = 0L;
			var notD = 1L;
			for (int i = 0; i < n; i++) {
				var newD = notD * 3 % 1000000007;
				notD = (d + notD * 2) % 1000000007;
				d = newD;
			}
			Console.WriteLine(d);
		}
	}
}


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

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			//string input2 = Console.ReadLine();

			var inputs1 = input1.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
			//var inputs2 = input2.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();

			int n = inputs1[0];
			int m = inputs1[1];

			if (n > m)
			{
				Console.WriteLine(n - m);
			}
			else if(n == m)
			{
				Console.WriteLine(0);
			}
			else
			{
				var count = (int)Math.Ceiling(Math.Log((double)m / n)) + (2 * n > m ? 0 : 1);
				var h = count + (n * Math.Pow(2, count) - m);
				var list = new List<int> { n };
				for (int i = 0; i < h; i++)
				{
					var newList = new List<int>();
					foreach (var item in list)
					{
						if (2 * item < 2 * m)
						{
							newList.Add(2 * item);
						}

						if (item - 1 > 0)
						{
							newList.Add(item - 1);
						}

						if (2 * item == m || item - 1 == m)
						{
							Console.WriteLine(i + 1);
							return;
						}
					}

					list = newList;
				}
			}
		}

		public class Node<T>
		{
			public Node<T> Left { get; set; }

			public Node<T> Right { get; set; }

			public T Value { get; set; }

			public Node(T value)
			{
				Value = value;
			}
		}

		public class Tree<T>
		{
			public Node<T> Root { get; set; }

			public Tree(T value)
			{
				Root = new Node<T>(value);
			}
		}

		//private static long GCD(long a, long b)
		//{
		//	long max = Math.Max(a, b);
		//	long min = Math.Min(a, b);

		//	if (min == 0)
		//	{
		//		return max;
		//	}

		//	a = min;
		//	b = max % min;
		//	return GCD(a, b);
		//}

		//private static long LCM(long a, long b)
		//{
		//	return Math.Abs(a * b) / GCD(a, b);
		//}

		//private static int Length(short[] a)
		//{
		//	int firstItemIndex = 0;
		//	for (int i = 0; i < a.Length; i++)
		//	{
		//		if (a[i] == 0)
		//		{
		//			continue;
		//		}

		//		firstItemIndex = i;
		//		break;
		//	}

		//	return a.Length - firstItemIndex;
		//}

		//private static short[] Subtract(short[] a, short[] b)
		//{
		//	if (a.Length != b.Length)
		//	{
		//		throw new ArgumentException();
		//	}

		//	short[] result = new short[a.Length];
		//	Array.Copy(a, result, a.Length);
		//	for (int i = result.Length - 1; i >= 0; i--)
		//	{
		//		if (result[i] < b[i])
		//		{
		//			int j = i - 1;
		//			while (result[j] == 0)
		//			{
		//				result[j--] = 9;
		//			}

		//			result[j]--;
		//			result[i] += 10;
		//		}

		//		result[i] -= b[i];
		//	}

		//	return result;
		//}

		//private static short[] Multiply(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	for (int i = a.Length - 1; i > 0; i--)
		//	{
		//		int temp = a[i] * b;
		//		result[i] = (short)(result[i] + temp % 10);
		//		result[i - 1] = (short)(result[i - 1] + temp / 10);
		//	}

		//	return result;
		//}

		//private static int Mod(short[] a, int b)
		//{
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		rest = d % b;
		//		i++;
		//	}

		//	return rest;
		//}

		//private static short[] Divide(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		result[i] = (short)(d / b);
		//		rest = d % b;
		//		i++;
		//	}

		//	return result;
		//}
	}
}


using System;
using System.Linq;

public static class Program
{
  public static void Main() {
    var str = Console.ReadLine();
    foreach (var c in str)
      if ((new [] {'A', 'O', 'Y', 'E', 'U', 'I'}).Contains(Char.ToUpper(c)))
        ;
      else
      {
        Console.Write('.');
        Console.Write(c.ToString().ToUpperCase());
      }
  }
}


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

class P {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var p = s.Take(4).ToArray();
    var a = s[4];
    var b = Math.Min(s[5], 1000);

    var perm = new List<int[]>();
    for (var i1 = 0 ; i1 < 4 ; i1++)
    for (var i2 = 0 ; i2 < 4 ; i2++)
    for (var i3 = 0 ; i3 < 4 ; i3++)
    for (var i4 = 0 ; i4 < 4 ; i4++)
      if (i1 != i2 && i1 != i3 && i1 != i4 && i2 != i3 && i2 != i4 && i3 != i4)
       perm.Add(new [] { i1, i2, i3 ,i4});

    var n = Enumerable.Range(a,b).Where(x => x <= b)
            .Count(x => perm.Aggregate(x, (acc,tmp) => acc %tmp) == x);
    Console.Write(n);
  }
}


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

class P {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var p = s.Take(4).ToArray();
    var a = s[4];
    var b = Math.Min(s[5], 1000);

    var perm = new List<int[]>();
    for (var i1 = 0 ; i1 < 4 ; i1++)
    for (var i2 = 0 ; i2 < 4 ; i2++)
    for (var i3 = 0 ; i3 < 4 ; i3++)
    for (var i4 = 0 ; i4 < 4 ; i4++)
      if (i1 != i2 && i1 != i3 && i1 != i4 && i2 != i3 && i2 != i4 && i3 != i4)
       perm.Add(new [] { i1, i2, i3 ,i4});

    var n = Enumerable.Range(a,b).Where(x => x <= b)
            .Count(x => perm.Count(
                  pp => pp.Aggregate(x, (acc,tmp) => acc %tmp) == x) >= 7);
    Console.Write(n);
  }
}


using System;

namespace CSharp
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            string[] numbers = Console.ReadLine().Split();
            JohnyNumber(int.Parse(numbers[0]), int.Parse(numbers[1]));
        }

        private static void JohnyNumber(int n, int k)
        {
            bool searching = true;
            int i = n + 1;
            while (searching)
            {
                if (i % k == 0)
                {
                    searching = false;
                }
                else
                    i++;
            }
            Console.WriteLine(i);
        }
    }
}


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

namespace test_cs
{

    class Program
    {

        static void Main(string[] args)
        {
            int n, m;
            var ss = Console.ReadLine();
            var parse = ss.Split(' ');
            n = Convert.ToInt32( parse[0] );
            m = Convert.ToInt32(parse[1]);

            long del = (long)(10e9 + 7);
            const int size = 100001;
            long[] arr = new long[size];

            arr[0] = 1;

            for (int i = 1; i < size; i++)
            {
                arr[i] = arr[i - 1];
                if (i > 2)
                {
                    arr[i] = ( arr[i] + arr[i - 2]);
                }
            }

            Console.WriteLine( (2 * (arr[n+1] + arr[m+1] - 1))%del );
            int b = 43;

            /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            string[] str_arr =
            {
                "ABCD",
                "ABDD",
                "ABDC",
            };

            for (int i = 0; i < 4; i++)
            {
                var ei = from cc in
                                (from a in str_arr
                                 select (from b in a
                                         select b).ElementAt(i)
                                    )
                         group cc by cc into newGrp
                         select newGrp;

                var max_el = (from ge in ei
                              select ge.Count()).Max();

                Console.WriteLine(max_el);
                var ei_arr = ei.ToArray();
                int bb = 54;
            }
            */

            /*
            foreach (var item in sorted_arr)
            {
                 Console.WriteLine(item);
            }
                      */

            /*
            foreach (var item in stringQuery)
            {
                Console.WriteLine(item);
            }

            */

            //Console.Read();
        }
    }
}


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

namespace ConsoleApplication5
{
    class Program
    {
        public static string f(int number)
        {
            Dictionary<int, string> dic = new Dictionary<int, string>();
            dic.Add(1, "one"); dic.Add(10, "ten");
            dic.Add(2, "two"); dic.Add(11, "eleven");
            dic.Add(3, "three"); dic.Add(12, "twelve");
            dic.Add(4, "four"); dic.Add(13, "thirteen");
            dic.Add(5, "five"); dic.Add(14, "fourteen");
            dic.Add(6, "six"); dic.Add(15, "fifteen");
            dic.Add(7, "seven"); dic.Add(16, "sixteen");
            dic.Add(8, "eight"); dic.Add(17, "seventeen");
            dic.Add(9, "nine"); dic.Add(18, "eighteen");
            dic.Add(19, "nineteen"); dic.Add(60, "sixty");
            dic.Add(20, "twenty"); dic.Add(70, "seventy");
            dic.Add(30, "thirty"); dic.Add(80, "eighty");
            dic.Add(40, "forty"); dic.Add(90, "ninety");
            dic.Add(50, "fifty");

            StringBuilder sbLine = new StringBuilder();
            if (number <= 20 || number%10 == 0)
            {
                return dic[number];
            }
            return dic[(number/10) * 10]+"-"+dic[number%10];
        }

        static void Main(string[] args)
        {
            int number = int.Parse(Console.ReadLine());
            Console.WriteLine(f(number));
        }
    }
}


using System;

namespace AllProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            _535A_TavasAndNafas.Run();
        }
    }
    public class _535A_TavasAndNafas
    {
        private static string[] NUMS = new string[] {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
        private static string[] TENS = new string[] {"ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};

        public static void Run()
        {
            var n1 = Console.ReadLine().Trim();
            var n = Int32.Parse(n1);
            Console.WriteLine(getWord(n));
        }

        private static string getWord(int n) {
            if (n < 20) {
                return NUMS[n - 1];
            } else {
                int mod = (n - 1) % 10;
                return TENS[(int)(n / 10) - 1] + (mod < 9 ? ("-" + NUMS[mod]): "");
            }
        }
    }
}


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)
        {
            var from = Console.ReadLine().ToCharArray();
            var to = Console.ReadLine().ToCharArray();
            var clonef = ((char[])from.Clone()).ToList();

            if (from.Length == to.Length && to.All(p=>{
                var contains = clonef.Contains(p);
                clonef.Remove(p);
                return contains;
            }))//array
            {
                Console.WriteLine("array");
            }
            else
            {
                if (to.All(p =>
                {
                    var contains = clonef.Contains(p);
                    clonef.Remove(p);
                    return contains;
                }))
                {
                    var i = 0;
                    var j = 0;
                    clonef = from.Clone();
                    while (i < to.Length && j < clonef.Count)
                    {
                        if (clonef[j] == to[i])
                        {
                            i++;
                            clonef.RemoveAt(j);

                        }
                        else
                        {
                            j++;
                        }
                    }

                    if (i == to.Length)
                    {
                        Console.WriteLine("automaton");
                    }
                    else
                    {

                        Console.WriteLine("both");
                    }
                }
                else
                {
                    Console.WriteLine("need tree");
                }
            }
        }
    }
}


using System;
using System.Data;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Principal;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.Web.Administration;

namespace XPathTest
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			AnotherTest();
			Console.ReadKey();
		}

		private static void TestUser()
		{
			Console.WriteLine(WindowsIdentity.GetCurrent().Name);
			var wp = new WindowsPrincipal(new WindowsIdentity(WindowsIdentity.GetCurrent().Token));
			var type = typeof(WindowsIdentity);
			var method = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).First(m => m.Name == "CreateFromToken");
			var obj = new WindowsIdentity(WindowsIdentity.GetCurrent().Token);
			var result = method.Invoke(obj, new object[] { WindowsIdentity.GetCurrent().Token });
			Console.WriteLine(obj.Name + " " + obj.Token);
			//Console.WriteLine(result.Name + " " + result.Token);
			Console.WriteLine(WindowsIdentity.GetCurrent().Token);
		}

		public static void AnotherTest()
		{
			var user = WindowsIdentity.GetCurrent().User;
			Console.WriteLine(user.AccountDomainSid);
		}

		private static void TestCreateAppDomain()
		{
			var domain = AppDomain.CreateDomain("TestDomain");
			Console.WriteLine(WindowsIdentity.GetCurrent().Token);
			domain.SetThreadPrincipal(new WindowsPrincipal(new WindowsIdentity(WindowsIdentity.GetCurrent().Token)));
			domain.ExecuteAssembly(@"C:\Users\Andrey.Titov\Documents\Visual Studio 2013\Projects\Test\ConsoleApplication2\bin\Debug\ConsoleApplication2.exe");
			var newDom = AppDomain.CreateDomain("Test");
			newDom.SetThreadPrincipal(new WindowsPrincipal(new WindowsIdentity(WindowsIdentity.GetCurrent().Token)));
			newDom.ExecuteAssembly(@"C:\Users\Andrey.Titov\Documents\Visual Studio 2013\Projects\Test\ConsoleApplication2\bin\Debug\ConsoleApplication2.exe");
			AppDomain.Unload(domain);
			AppDomain.Unload(newDom);
			Console.WriteLine(WindowsIdentity.GetCurrent().Token);
		}

		private static void ProgramFilesTest()
		{
			Console.WriteLine(Environment.ExpandEnvironmentVariables(@"%SYSTEMROOT%\Microsoft.NET\Framework\v4*"));
		}

		private static void Test()
		{
			var dir = new DirectoryInfo(@"C:\Windows\System32\inetsrv\config");
			foreach (var fileInfo in dir.EnumerateFiles()) {
				Console.WriteLine(fileInfo.Name);
			}
			//var doc = new XmlDocument();
			//doc.Load(@"C:\Windows\System32\inetsrv\config\applicationHost.config");
			//XmlNode root = doc.DocumentElement;

			//XmlNode node = root.SelectSingleNode(@"/configuration/configSections/sectionGroup[@name='system.webServer']/section[@name='handlers']");
			//foreach (XmlAttribute attr in node.Attributes)
			//{
			//	Console.WriteLine(attr.Name);
			//}
		}

		private static void Machine()
		{
			using (var context = new PrincipalContext(ContextType.Machine)) {
				using (var searcher = new PrincipalSearcher(new UserPrincipal(context))) {
					foreach (var result in searcher.FindAll()) {
						var de = result.GetUnderlyingObject() as DirectoryEntry;
						var samAccountName = de.Properties["samAccountName"].Value;
						var name = de.Properties["Name"].Value;
						Console.WriteLine(samAccountName);
						Console.WriteLine(name);
						Console.WriteLine();
					}
				}
			}
		}

		private static void TestWin10()
		{
		}

		private static void Ad()
		{
			using (var context = new PrincipalContext(ContextType.Domain, "INTRANET")) {
				using (var searcher = new PrincipalSearcher(new UserPrincipal(context))) {
					foreach (var result in searcher.FindAll()) {
						var de = result.GetUnderlyingObject() as DirectoryEntry;
						var samAccountName = de.Properties["samAccountName"].Value;
						var name = de.Properties["Name"].Value;
						Console.WriteLine(samAccountName);
						Console.WriteLine(name);
						Console.WriteLine();
					}
				}
			}
		}

		private static void TestSqlServers()
		{
			DataTable localServers = SmoApplication.EnumAvailableSqlServers(true);
			DataRow[] rows = localServers.Select(string.Empty, "IsLocal desc, Name asc");
			DataTable netServers = SmoApplication.EnumAvailableSqlServers();
			var netRows = netServers.Select(string.Empty, "IsLocal desc, Name asc");
			var totalRows = rows.Concat(netRows).ToArray();
			foreach (var row in netRows)
			{
				Console.WriteLine(row[0]);
			}
		}
	}
}


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

    class Program
    {
        static void Main(string[] args)
        {
            string h = Console.ReadLine();

            int m = Convert.ToInt32(h.Substring(0, 1));
            int n = Convert.ToInt32(h.Substring(2, 1));

            int s = 0;
            int p = 0;
            int a = 0, b = 0, q = 0;

            if (m > n)
            {
                q = Convert.ToInt32(Math.Sqrt(m));
                while (s <= m)
                {
                    if (q * q + s == m)
                    {
                        a = q;
                        b = m - q * q;

                        if (a + b * b == n)
                        {
                            p++;
                        }
                    }
                    s = s + 1;
                }
            }

            else
            {
                q = Convert.ToInt32(Math.Sqrt(n));

                while (s <= n)
                {
                    if (q * q + s == n)
                    {
                        b = q;
                        a = n - q * q;

                        if (a * a + b == m)
                        {
                            p++;
                        }
                    }
                    s = s + 1;
                }
            }

            Console.WriteLine(p);

        }
    }


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

namespace contest214
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            int m;
            int c = 0;

            n = Convert.ToInt32(Console.ReadLine());
            m = Convert.ToInt32(Console.ReadLine());

            for (int a = 0; a < 1000; a++)
            {
                for (int b = 0; b < 1000; b++)
                {
                    if ((a * a + b == n) && (a + b * b == m) && m <= 1000 && n >= 1) c++;
                }
            }

            Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
           try
            {
                int m = int.Parse(Console.ReadLine());
                int[] ar = new int[6];
                for (int i = 0; i < m; i++)
                {
                    int[] ar2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    ar[ar2[0]-1]++;
                    ar[ar2[1]-1]++;
                }
                int c = 0;
                if (m % 2 == 0)
                    c = m / 2;
                else
                    c = m / 2 + 1;
                bool q = false;
                for (int i = 0; i < 5; i++)
                {
                    if(ar[i]>=c)
                    {
                        q = true;
                        break;
                    }
                }
                if(q)
                    Console.WriteLine("WIN");
                else
                    Console.WriteLine("FAIL");
                Console.ReadKey();
           }
          catch { }
        }

    }
}


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

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }
        object Solve()
        {
            var n = ReadLong();
            var a = ReadLongs();
            var res = 0;
            var flag = false;
            for (int i = 0; i < n - 1; i++)
            {
                if (a[i] == 1 && a[i + 1] == 0)
                    res++;
            }
            return n - res;

        }

        long CalcRow(string s)
        {
            long zeros = s.Count(x => x == '0');
            //if (zeros % s.Length == 0)
            //    return s.Length;
            return FastPow(2, zeros) + FastPow(2, s.Length - zeros) - 2;
        }

        long CalcCol(string[] grid, int col)
        {
            long zeros = grid.Select(x => x[col]).Count(x => x == '0');
            return FastPow(2, zeros) + FastPow(2, grid.Length - zeros) - 2;
        }

        long FastPow(long b, long pow)
        {
            if (pow == 0)
                return 1;
            if (pow == 1)
                return b;
            if (pow % 2 == 0)
                return FastPow(b * b, pow / 2);
            return FastPow(b, pow - 1) * b;
        }

        class Put
        {
            public long Left { get; set; }
            public long Right { get; set; }
            public long Cost { get; set; }

            public long Length() { return Right - Left + 1; }
        }

        bool Match(string s, string template, string good)
        {
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != template[i] && (template[i] != '?' || good.IndexOf(s[i]) == -1))
                    return false;
            }
            return true;
        }

        class Vac
        {
            public long Left { get; set; }
            public long Right { get; set; }
            public long Cost { get; set; }
        }

        class End
        {
            public long Val { get; set; }
            public bool Left { get; set; }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10)
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            //var i = s.IndexOf(' ');
            //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }

}


<Query Kind="Program" />

void Main()
{
	int n =int.Parse(Console.ReadLine());

	string[] game = Console.ReadLine().Split();
	int[]  ans = new int [n];

	for (int k=0;k<n;k++)
	{
		if (k>0) ans[k] = ans[k-1];
		if (game[k]=="0") ans[k]++;
	}
	int max = 0;
	int t = 0;

	for (int i =0;i<n;i++)
	{
		t= 1;
		if (i<n-1) t+=n-ans[n-1] - (i+1-ans[i]);
		if (i>0) t+= ans[i-1];
		if (max<t)
			max = t;
	}
	Console.WriteLine(max);
}

// Define other methods and classes here


using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputArgs = Console.ReadLine().Split(' ');

            int[] size = new int[3];

            size[0] = int.Parse(inputArgs[0]);
            size[1] = int.Parse(inputArgs[1]);
            size[2] = int.Parse(inputArgs[2]);
            int k = int.Parse(inputArgs[3]);

            Array.Sort(size);

            int[] beats = new int[3];

            for (int i = 0; i < 3; i++)
            {
                beats[i] = (k / (3 - i) > size[i] - 1) ? size[i] - 1 : k / (3 - i);
                k -= beats[i];
            }

            ulong result = (ulong)((beats[0] + 1) * (beats[1] + 1) * (beats[2] + 1));

            Console.WriteLine(result);
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round66
{
    class A
    {
        public static void Main()
        {
            var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss=>int.Parse(sss));
            int k = xs[3];
            long a = 1+(k + 2) / 3,
                b = 1 + (k + 1) / 3,
                c = 1 + k / 3;
            Console.WriteLine(a*b*c);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        public static long GCD(long a, long b)
        {
            long n = a;
            long t = b;
            while (t != 0)
            {
                n %= t;
                long s = n;
                n = t;
                t = s;
            }
            return n;
        }

        static long f(long n)
        {
            if (n == 1)
                return 1;
            long ans = 0;
            for(long i = 1; i <= n/2;i++)
            {
                if(GCD(n,i) == 1)
                {
                    ans += 2;
                }
            }
            return ans;
        }
        static void Main()
        {
            string[] token = Console.ReadLine().Split(' ');
            long n = long.Parse(token[0]);
            long k = long.Parse(token[1]);
            long t = (k + 1) / 2;
            long ans = f(n);
            while(t != 1)
            {
                ans = f(ans);
                t--;
            }
            Console.WriteLine(ans);
            Console.Read();
        }
    }
}