﻿using System;
class MaxIncreasingSequence
{
    static void Main()
    {

        //Write a program that finds the maximal increasing sequence in an array.

        Console.WriteLine("====Maximal increasing sequence program!====\n");

        //Enter numbers from console
        //Console.WriteLine("Enter array's lenght");
        //int arraysLength = int.Parse(Console.ReadLine());
        //int[] arrayIntegers = new int[arraysLength];


        // Manual :D
        //
        //int[] arrayIntegers = { 3, 2, 3, 4, 2, 2, 4 }; // 2, 3, 4
        //int[] arrayIntegers = { 3, 2, 3, 4, 5, 6, 7, 2, 2, 4, 5, 6, 7, 8, 9, 10, 11 }; //4, 5, 6, 7, 8, 9, 10, 11
        int[] arrayIntegers = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 3, 2, 3, 4, 5, 6, 7, 2, 2, 4, 5, 6, 7, 8, 9, 10, 11 };
        //4, 5, 6, 7, 8, 9, 10, 11, 12
        //
        int longestSequence = 0;
        int element = 0;
        int counterForSequence = 0;
        int lastCheckedElement = 0;

        //thats for the console
        //for (int i = 0; i < arrayIntegers.Length; i++)
        //{
        //    Console.Write("Enter element {0}: ", i + 1); //i+1 just for nice look
        //    arrayIntegers[i] = int.Parse(Console.ReadLine());

        //}

        for (int i = 0; i < arrayIntegers.Length; i++) //I can make this checks in the for above, but
        //by that way i am sure that my program will work with defined arrays
        {

            if (i == 0)
            {
                //longestSequence = 1;
                element = arrayIntegers[0];
                counterForSequence++;
                lastCheckedElement = arrayIntegers[i];
            }
            else
            {
                if (arrayIntegers[i] <= lastCheckedElement)
                {
                    if (counterForSequence > longestSequence)
                    {
                        longestSequence = counterForSequence;
                        element = lastCheckedElement;

                    }
                    counterForSequence = 1;
                }
                else
                {
                    counterForSequence++;
                }
                lastCheckedElement = arrayIntegers[i];
            }
        }
        counterForSequence--;
        if (counterForSequence > longestSequence)
        {
            longestSequence = counterForSequence;
            element = lastCheckedElement;
        }
        for (int i = longestSequence - 1; i >= 0; i--)
        {

            Console.Write("{0} ", element - i);
        }
        //Main();
    }
}
