import java.util.*;

public class Solution 
{
    public static void main (String[] args)
    {
        //************ALL DOCUMENTED TEST CASES**********
        //Ascending
        //float[] nums = new float[]{0f,2f,3f,4f,6f,8f,9f};   //Test case 1    PASS             
        //float[] nums = new float[]{-1f};   //Test case 2             PASS             
        //float[] nums = new float[]{0f};   //Test case 3       PASS                    
        //float[] nums = new float[]{0,1f,2,4f,5,7f};   //Test case 4    PASS            
        
        //Descending
        //float[] nums = float int[]{9f,8f,6f,4f,3f,2f,0f};    PASS            
        //float[] nums = new float[]{-1f};                PASS             
        //float[] nums = new float[]{0f};          PASS                    
        //float[] nums = new float[]{7f,5f,4f,2f,1f,0f};      PASS 
        
        //For some reason, no test cases above went through junction 8. All others are valid.
        //So these were new devised cases.....
        //float[] nums = new float[]{0f,1f,2f,4f,5f,7f,8f,10f,14f};   //Test case 4    PASS            
        //float[] nums = new float[]{0f,2f,4f,5f,7f,8f,10f,14f,17f,19f,23f,24f,25f,26f,35f,42f,43f,44f};  PASS     
        //float[] nums = new float[]{5f,4f,3f,4f,5f,7f,6f,10f,14f,17f,19f,23f,24f,25f,26f,35f,42f,47f,60f,61f};  PASS
        //float[] nums = new float[]{7f,6f,9f,3f,5f,8f};
        
        //Merging both ascending and descending code
        //float[] nums = new float[]{5f,4f,3f,4f,5f,6f,8f,8f};   PASS
        //float[] nums = new float[]{5f,4f,3f,4f,5f,7f,6f,5f,10f,14f,17f,19f,23f,24f,25f,26f,35f,34f,33f,47f};  PASS
        
        //float[] nums = new float[]{5f,6f,7f,6f,5f,9f,10f,11f,44f,45f,46f,47f,46f,45f,44f,43f,25f,24f,24f,23f,23f,22f};  //using ascending, descending and non-changing....PASS
        
        //float[] nums = new float[]{5f,9f,13f,2f,3f,4f,3f,1f,2f,3f,4f,5f,6f,22f,66f,65f,65f,64f,63f,90f,89f,60f}; //using standalone numbers in between and also ascending/descending...PASS
        //float[] nums = new float[]{1.5f,1.9f,  1.13f,  1.2f, 1.3f, 1.4f, 1.5f, 1.3f,  1.1f,  1.2f};
        
        //float[] nums = new float[]{1.5f,1.9f,  1.13f,  1.2f, 1.1f, 1.4f, 1.5f, 1.3f,  1.1f,  1.2f};
        
        //float[] nums = new float[]{2.0f,4.0f,2.0f,1.2f,1.3f,1.4f,1.3f,1.1f,1.2f,1.3f,1.4f,1.5f,1.6f,1.22f,1.66f,1.65f,1.65f,1.64f,1.63f,1.90f,1.89f,1.60f}; 
        
        //repeat numbers
        //float[] nums = new float[]{2,2,2,4,4,1,1,9,9};  PASS
        
        
        float[] nums = {
        //4.9f, 4.8f, 4.7f, 4.6f, 4.7f, 4.8f, 4.9f, 5.0f, 48.5f, 91.7f  //in test documentation,  used to test the transition 4.6
        //4.9f, 4.8f, 4.7f, 4.5f, 4.6f, 4.7f, 4.9f, 5.0f, 48.5f, 91.7f  //in test documentation , used to test 4.5f standalone merging upwards into ascending
        //0.9f, 0.8f, 0.7f, 0.6f, 0.7f, 0.8f, 0.9f, 5.0f   //test case in documentation where I resolved end of range with standalone....
        //86.0f,77.7f, 77.8f, 77.9f, 78.0f, 78.1f,78.0f, 77.9f, 77.8f, 77.7f, 25.3f, 72.8f, 42.5f   //this will be section of the ChatGPT data in order to ensure I can resolve issues quicker
        //25.3f, 72.8f,42.5f, 74.5f, 74.4f, 74.3f, 74.2f, 74.1f, 74.2f, 74.3f, 74.4f,74.5f   //this will be section of the ChatGPT data in order to ensure I can resolve issues quicker
        //47.3f, 47.2f, 47.3f, 47.4f,47.5f  //issues encountered at end of the chatGPT array. it did not merge last two items.
        
        //47.4f, 47.3f,47.4f   //realised at end of the documentation, that this is failing...
        //47.3f, 47.4f,47.3f   // NEED TO FIX THIS ALSO, resolved as part of the above one...
        //47.4f, 47.3f,47.5f  //NEED TO FIX THIS ALSO
        //47.3f, 47.4f,47.5f  //late fixes in code   -  FAIL   (this is straight forward ascending)  -  FAIL************
        //47.3f, 47.2f,47.3f,47.4f  //late fixes in code 
        //47.4f,47.3f,47.2f,47.4f  //late fixes in code
        //47.3f,47.2f,47.3f,47.4f,47.5f  //late fixes in code
        //47.3f,47.2f,47.3f //late fixes in code
         //47.2f,47.3f,47.2f //late fixes in code
        //47.2f,47.3f,47.2f,47.1f //late fixes in code
        
        //this is first chatGPT extract
        //30032025/SummaryRange/5/4/ChatGPTgeneratedNumbers.txt
        //4.9f, 4.8f, 4.7f, 4.6f, 4.7f, 4.8f, 4.9f, 5.0f, 48.5f, 91.7f, 82.9f, 57.6f, 57.5f, 57.4f, 57.3f, 57.2f, 57.3f, 57.4f, 57.5f, 57.6f, 26.1f, 25.4f, 21.2f, 83.5f, 56.3f, 56.2f, 56.1f, 56.0f, 55.9f, 55.8f, 55.7f, 55.6f, 13.9f, 35.7f, 54.8f, 54.7f, 54.6f, 54.5f, 54.6f, 54.7f, 54.8f, 54.9f, 49.9f,  9.6f, 86.0f, 77.7f, 77.8f, 77.9f, 78.0f, 78.1f, 78.0f, 77.9f, 77.8f, 77.7f, 25.3f, 72.8f, 42.5f, 74.5f, 74.4f, 74.3f, 74.2f, 74.1f, 74.2f, 74.3f, 74.4f, 74.5f, 90.6f, 30.0f, 66.5f, 11.2f, 64.2f, 64.3f, 64.4f, 64.5f, 64.6f, 64.5f, 64.4f, 64.3f, 64.2f, 18.8f, 49.3f, 60.3f, 51.1f, 52.5f, 52.4f, 52.3f, 52.2f, 52.1f, 52.0f, 51.9f, 51.8f,  1.8f, 70.5f, 69.2f, 79.8f, 86.7f, 86.6f, 86.5f, 86.4f, 86.3f, 86.4f, 86.5f, 86.6f, 86.7f, 17.9f, 80.8f, 23.9f, 89.6f, 36.0f, 35.9f, 35.8f, 35.7f, 35.6f, 35.7f, 35.8f, 35.9f, 36.0f, 95.8f, 28.9f, 71.6f,  5.3f, 60.0f, 60.1f, 60.2f, 60.3f, 60.4f, 60.3f, 60.2f, 60.1f, 60.0f, 45.2f, 16.2f, 50.6f, 34.1f, 68.4f, 68.3f, 68.2f, 68.1f, 68.0f, 67.9f, 67.8f, 67.7f, 67.6f, 89.9f, 27.1f, 14.4f, 98.9f, 63.8f, 63.9f, 64.0f, 64.1f, 64.2f, 64.1f, 64.0f, 63.9f, 63.8f, 54.8f, 22.6f, 41.1f, 91.4f, 47.9f, 47.8f, 47.7f, 47.6f, 47.5f, 47.6f, 47.7f, 47.8f, 47.9f, 58.5f, 70.8f, 11.3f, 58.6f, 58.7f, 58.8f, 58.9f, 59.0f, 58.9f, 58.8f, 58.7f, 58.6f, 35.3f, 76.8f, 44.2f, 96.7f, 52.0f, 51.9f, 51.8f, 51.7f, 51.6f, 51.5f, 51.4f, 51.3f, 51.2f, 20.3f, 93.8f, 37.8f, 61.8f, 30.6f, 30.7f, 30.8f, 30.9f, 31.0f, 30.9f, 30.8f, 30.7f, 30.6f, 12.1f, 84.4f,  2.9f, 63.2f, 69.7f, 69.6f, 69.5f, 69.4f, 69.3f, 69.4f, 69.5f, 69.6f, 69.7f, 55.4f, 81.6f, 32.4f,  6.0f, 79.8f, 79.9f, 80.0f, 80.1f, 80.2f, 80.1f, 80.0f, 79.9f, 79.8f, 88.2f, 21.3f, 45.1f, 90.3f, 42.3f, 42.2f, 42.1f, 42.0f, 41.9f, 41.8f, 41.7f, 41.6f, 41.5f, 62.9f, 97.6f, 53.1f, 24.7f, 66.0f, 65.9f, 65.8f, 65.7f, 65.6f, 65.7f, 65.8f, 65.9f, 66.0f, 49.6f, 83.5f, 38.6f, 10.4f, 77.6f, 77.5f, 77.4f, 77.3f, 77.2f, 77.3f, 77.4f, 77.5f, 77.6f,  3.1f, 60.6f, 88.0f, 92.6f, 74.6f, 74.7f, 74.8f, 74.9f, 75.0f, 74.9f, 74.8f, 74.7f, 74.6f, 31.4f, 13.4f, 55.7f, 64.5f, 50.2f, 50.1f, 50.0f, 49.9f, 49.8f, 49.9f, 50.0f, 50.1f, 50.2f, 58.0f, 67.8f, 41.3f, 96.8f, 72.3f, 72.2f, 72.1f, 72.0f, 71.9f, 71.8f, 71.7f, 71.6f, 71.5f, 29.7f, 81.9f, 18.0f, 46.4f, 34.3f, 34.4f, 34.5f, 34.6f, 34.7f, 34.6f, 34.5f, 34.4f, 34.3f, 85.7f, 14.3f, 26.5f, 56.9f, 61.6f, 61.5f, 61.4f, 61.3f, 61.2f, 61.1f, 61.0f, 60.9f, 60.8f, 43.6f, 89.0f,  7.1f, 75.2f, 39.2f, 39.1f, 39.0f, 38.9f, 38.8f, 38.9f, 39.0f, 39.1f, 39.2f, 94.9f, 23.7f, 48.2f, 87.2f, 52.8f, 52.9f, 53.0f, 53.1f, 53.2f, 53.1f, 53.0f, 52.9f, 52.8f, 12.8f, 97.0f, 20.7f, 68.9f, 73.1f, 73.0f, 72.9f, 72.8f, 72.7f, 72.6f, 72.5f, 72.4f, 72.3f, 54.6f, 15.5f, 40.1f, 30.8f, 63.5f, 63.4f, 63.3f, 63.2f, 63.1f, 63.0f, 62.9f, 62.8f, 62.7f, 49.2f,  5.9f, 91.5f, 84.7f, 51.0f, 50.9f, 50.8f, 50.7f, 50.6f, 50.7f, 50.8f, 50.9f, 51.0f, 78.7f, 36.4f, 59.9f, 95.3f, 44.9f, 44.8f, 44.7f, 44.6f, 44.5f, 44.4f, 44.3f, 44.2f, 44.1f, 83.6f, 25.9f, 32.1f, 11.1f, 67.5f, 67.4f, 67.3f, 67.2f, 67.1f, 67.2f, 67.3f, 67.4f, 67.5f, 52.7f, 98.0f, 19.5f, 60.7f, 28.1f, 28.0f, 27.9f, 27.8f, 27.7f, 27.8f, 27.9f, 28.0f, 28.1f, 70.7f, 54.5f, 13.5f, 77.1f, 41.2f, 41.1f, 41.0f, 40.9f, 40.8f, 40.7f, 40.6f, 40.5f, 40.4f, 59.4f, 90.0f,  6.7f, 85.4f, 69.5f, 69.6f, 69.7f, 69.8f, 69.9f, 70.0f, 70.1f, 70.2f, 70.3f, 38.0f, 12.4f, 95.2f, 57.1f, 50.4f, 50.3f, 50.2f, 50.1f, 50.0f, 49.9f, 49.8f, 49.7f, 49.6f, 61.7f, 27.6f, 43.1f, 83.8f, 73.4f, 73.5f, 73.6f, 73.7f, 73.8f, 73.7f, 73.6f, 73.5f, 73.4f, 16.3f, 97.2f, 21.5f, 66.2f, 47.1f, 47.2f, 47.3f, 47.4f, 47.5f, 47.4f, 47.3f, 47.2f, 47.1f, 33.5f, 76.3f, 42.9f,  4.3f, 62.4f, 62.3f, 62.2f, 62.1f, 62.0f, 61.9f, 61.8f, 61.7f, 61.6f, 82.4f, 24.4f, 58.4f,  9.7f, 90.4f, 90.3f, 90.2f, 90.1f, 90.0f, 89.9f, 89.8f, 89.7f, 89.6f, 34.9f, 14.7f, 30.2f, 96.2f, 52.4f, 52.3f, 52.2f, 52.1f, 52.0f, 51.9f, 51.8f, 51.7f, 51.6f, 71.8f, 59.2f, 10.6f, 84.2f, 63.7f, 63.8f, 63.9f, 64.0f, 64.1f, 64.0f, 63.9f, 63.8f, 63.7f, 46.6f, 18.2f, 45.4f, 82.0f, 78.6f, 78.5f, 78.4f, 78.3f, 78.2f, 78.3f, 78.4f, 78.5f, 78.6f, 95.4f, 32.6f, 23.3f, 68.8f, 41.8f, 41.7f, 41.6f, 41.5f, 41.4f, 41.3f, 41.2f, 41.1f, 41.0f, 58.9f, 27.4f, 56.1f, 88.7f, 50.8f, 50.9f, 51.0f, 51.1f, 51.2f, 51.1f, 51.0f, 50.9f, 50.8f, 12.9f, 72.1f, 33.3f, 67.9f, 74.9f, 74.8f, 74.7f, 74.6f, 74.5f, 74.6f, 74.7f, 74.8f, 74.9f, 49.0f, 21.9f, 61.2f, 93.6f, 55.3f, 55.2f, 55.1f, 55.0f, 55.1f, 55.2f, 55.3f, 55.4f, 55.5f, 43.4f, 61.0f, 47.3f, 47.4f
        
        //small extract taken from second chatGPT extract    
        //40.1f, 40.1f, 35.1f, 35.2f, 35.3f, 35.2f, 35.1f, 85.6f, 85.5f, 85.4f, 85.3f, 85.2f,19.6f, 19.7f, 19.8f, 19.9f, 20.0f, 19.9f, 19.8f, 63.5f    
   
        //this is second chatGPT extract   30032025/SummaryRange/5/4/ChatGPTgeneratedNumbersBetterDataSet.txt     
        //75.0f, 75.0f, 95.6f, 95.7f, 95.8f, 95.9f, 96.0f, 96.1f, 40.1f, 40.1f    //************************FAIL
        
        //this is second chatGPT extract
        //30032025/SummaryRange/5/4/ChatGPTgeneratedNumbersBetterDataSet.txt
        75.0f, 75.0f, 95.6f, 95.7f, 95.8f, 95.9f, 96.0f, 96.1f, 40.1f, 40.1f,35.1f, 35.2f, 35.3f, 35.2f, 35.1f, 85.6f, 85.5f, 85.4f, 85.3f, 85.2f, 19.6f, 19.7f, 19.8f, 19.9f, 20.0f, 19.9f, 19.8f, 63.5f, 14.9f, 14.9f, 48.6f, 48.5f, 48.4f, 48.3f, 48.2f, 48.3f, 48.4f, 48.5f, 48.6f, 65.2f, 82.1f, 82.2f, 82.3f, 82.4f, 82.5f, 82.4f, 82.3f, 82.2f, 82.1f, 28.9f, 28.8f, 28.7f, 28.6f, 28.5f, 28.4f, 28.3f, 28.2f, 28.1f, 28.0f, 39.0f, 33.6f, 33.7f, 33.8f, 33.9f, 34.0f, 34.1f, 34.2f, 34.3f, 75.9f, 75.9f, 54.3f, 54.2f, 54.1f, 54.0f, 53.9f, 54.0f, 54.1f, 54.2f, 54.3f, 11.5f, 91.4f, 91.5f, 91.6f, 91.7f, 91.8f, 91.7f, 91.6f, 91.5f, 91.4f, 66.8f, 66.9f, 67.0f, 67.1f, 67.2f, 67.3f,  7.7f,  7.7f, 49.6f, 49.6f, 49.6f, 57.7f, 57.8f, 57.9f, 58.0f, 58.1f, 58.0f, 57.9f, 57.8f, 57.7f, 24.2f, 70.5f, 70.4f, 70.3f, 70.2f, 70.1f, 70.0f, 69.9f, 69.8f, 69.7f, 92.2f, 31.3f, 31.4f, 31.5f, 31.6f, 31.7f, 31.8f, 31.7f, 31.6f, 31.5f, 31.4f, 13.3f, 13.3f, 86.4f, 86.3f, 86.2f, 86.1f, 86.0f, 85.9f, 85.8f, 85.7f, 45.0f, 45.1f, 45.2f, 45.3f, 45.4f, 45.5f, 45.4f, 45.3f, 45.2f, 45.1f, 22.2f, 22.2f, 22.2f, 99.0f, 98.9f, 98.8f, 98.7f, 98.6f, 98.5f, 98.6f, 98.7f, 98.8f, 98.9f, 99.0f, 12.8f, 12.9f, 13.0f, 13.1f, 13.2f, 13.3f, 13.4f, 13.5f, 13.6f, 13.7f, 55.4f, 55.5f, 55.6f, 55.7f, 55.8f, 55.9f, 55.8f, 55.7f, 55.6f, 55.5f, 40.2f, 40.2f, 40.2f, 83.0f, 82.9f, 82.8f, 82.7f, 82.6f, 82.5f, 82.4f, 82.5f, 82.6f, 82.7f, 82.8f,30.8f, 30.9f, 31.0f, 31.1f, 31.2f, 31.1f, 31.0f, 30.9f, 30.8f, 18.5f,62.9f, 63.0f, 63.1f, 63.2f, 63.3f, 63.4f, 63.3f, 63.2f, 63.1f, 63.0f,41.2f, 41.1f, 41.0f, 40.9f, 40.8f, 40.7f, 40.6f, 40.5f, 40.4f, 40.3f,18.7f, 18.8f, 18.9f, 18.8f, 18.7f, 60.7f, 60.6f, 60.5f, 60.4f, 60.3f,60.4f, 60.5f, 60.6f, 60.7f, 71.3f, 71.4f, 71.5f, 71.6f, 71.7f, 71.6f,71.5f, 71.4f, 71.3f, 55.1f
       
       //focussing on 2-3 runs of ascending/descending and overlapping transition
       
         //*****************************************************
         
         //****PASS CASES*************************************************************************
         //3.5f,3.6f,3.5f,3.6f   //ascending descending ascending 
        //3.5f,3.6f,3.5f,3.2f,3.1f   //ascending descending descending
        //3.5f,3.6f,3.5f,3.1f,3.0f,2.9f   //ascending descending descending
        //3.5f,3.4f,3.0f,2.9f,2.5f,2.4f   //descending descending descending
        //3.5f,3.4f,3.0f,2.9f,4.5f,4.6f   //descending descending ascending
        //3.5f,3.4f,3.5f,3.4f   //descending ascending descending
        //3.0f,2.7f,2.5f,2.4f,2.5f,2.6f  //changed last digit, want to see how it handles this  ****FAIL**************
        //3.5f,3.4f,3.5f,3.6f,32.1f,32.2f   //descending ascending ascending
        //3.5f,3.6f, 3.5f, 3.6f, 3.5f,3.4f,3.0f,2.9f,2.5f,2.4f  //ascending descending ascending  descending descending descending
        //5.0f,4.9f,4.8f  //most basic desecnding
        //47.3f, 47.4f,47.5f  //(RESOLVED)
        //47.3f, 47.4f
        //3.0f,2.7f,2.5f,2.4f,2.5f,2.6f  //(RESOLVED)
        //3.0f,2.7f,2.5f,2.4f,2.5f,4.0f  //exploring above scenario but the descend is slightly longer  ***FAIL**********  (RESOLVED)
        
        
        //***FAIL******************************************
        //3.5f,3.6f,40.1f,4.1f,40.0f   //ascending standalone  (it has only written standalone cases)
        //3.5f,3.6f,40.0f,40.1f,40.f   //it has not written  3.5f,3.6f,40.0f
        //3.5f,3.6f,40.0f,40.1f,56.2f,56.3f  //ascending ascending ascending   (writing 3.5->40.1, 56.2->56.3)
        //75.0f, 75.0f, 95.6f, 95.7f, 95.8f, 95.9f, 96.0f, 96.1f, 40.1f, 40.1f  (does not write standalones at end)
        
        
        };
       
        System.out.println(summaryRanges(nums));
    }
    
    public static List<String> summaryRanges(float[] nums) 
    {
        boolean includeStandalone=false;
        final float epsilon = 0.0005f;
        boolean writtenPrevious=false;   
        boolean combineMerge=false;
        String potentialfurtherAscendingBeyondThisStart="";
        String potentialfurtherAscendingBeyondThisEnd="";
        
        boolean hasNotWrittenLastNumber=true;
        
        boolean isFirstOccurenceAscendingChain=false;
        boolean isFirstOccurenceAscendingChainNoTransition =false;
        
        List<String> sm = new ArrayList<>();
        int counter = 0;
        String start="";
        String end="";
        String temp="";
        String backupStart="";
        boolean hasTransition=false;
        String transitionNumber="";
        float difference=0.1f;

        if (nums.length==1)
        {
            sm.add(String.valueOf(nums[0]));
            System.out.println("1Writing Standalone: " + nums[0]);
            return sm;
        }

        for (int k=0; k<nums.length-1;k++)
        {
            if (k==0)
            {
                start=String.valueOf(nums[k]);
            }
            
            if (nums[k]!=nums[k+1])
            {
                System.out.println("CHECKING: " + nums[k] + " with " + nums[k+1]);
                
                //if (includeStandalone)
                //{
                 //       start=String.valueOf(nums[k+1]);
                  //      sm.add(start);
                //        System.out.println("Including standalone due to configuration such as: " + "3.0f,2.7f,2.5f,2.4f,2.5f,4.0f");
                 //       System.out.println("5Writing standalone: " + start);
                  //      includeStandalone=false;
                //        break;
                //}
                
                //this will ensure that if data such as  3.5f,3.6f, (3.5f, 3.6f), 3.5f,3.4f,3.0f,2.9f,2.5f,2.4f
                //is stored..
                //otherwise it will get lost since following number 3.5f is lower....
                //we also need to perform comparison with potentialfurtherAscendingBeyondThisStart since its only way to ascertain
                //if nums[k+1] is deflecting opposite direction.... in which case activate this loop
if (!potentialfurtherAscendingBeyondThisStart.equals("") && !(potentialfurtherAscendingBeyondThisEnd.equals("")) && nums[k+1]<=Float.valueOf(potentialfurtherAscendingBeyondThisStart))
                {
                        System.out.println("using stored start");
                        sm.add(potentialfurtherAscendingBeyondThisStart+"->"+potentialfurtherAscendingBeyondThisEnd);
                        System.out.println("19731Writing range: " + start+"->"+end);
                        potentialfurtherAscendingBeyondThisEnd="";
                        potentialfurtherAscendingBeyondThisStart="";
                }
            
                //useful to identify the epsilon based on the difference
                System.out.println(nums[k]+difference);
                System.out.println(nums[k]-difference);
                
                
                //in descending sequence
                if (Math.abs(nums[k] - (nums[k+1] + difference)) <epsilon)
                {
                    System.out.println("HEREEEEE");
                    if (counter==0)
                    {
                        backupStart=String.valueOf(nums[k]);
                    }
                    
                    if (counter==0 && (k==nums.length-2))
                    {
                        start=String.valueOf(nums[k]);
                        end = String.valueOf(nums[k+1]);
                        sm.add(start+"->"+end);
                        System.out.println("5Writing range: " + start + "-> " + end);
                        isFirstOccurenceAscendingChain=false;
                        isFirstOccurenceAscendingChainNoTransition =false;
                        break;
                    }
                
                    if (counter!=0 && (k==nums.length-2))
                    {
                        end=String.valueOf(nums[k+1]);
                        sm.add(start +"->"+end);
                        System.out.println("6Writing range: " + start + "-> " + end); 
                    }
                    System.out.println("HERE!!!!");
                    if (counter==0)
                    {
                        if (isFirstOccurenceAscendingChainNoTransition || isFirstOccurenceAscendingChain)
                        {
                            end=String.valueOf(nums[k]);
                            sm.add(start+"->"+end);
                            System.out.println("28Writing range: " + start + "-> " + end);
                            isFirstOccurenceAscendingChain=false;
                            isFirstOccurenceAscendingChainNoTransition =false;
                        }
                        else
                        {
                            System.out.println("IN HERE!!!!");
                            //due to design of the code, this is a location for which it can make a decision here to perform a write (3.5->3.6) for 
                            //(3.5f,3.6f),3.5f,3.6f   by performing comparison of difference. However it would need to look two numbers ahead [k+2]
                            //this is something I have not done in my code at all..
                            //also I do not believe it will cause an exception anywhere... since if there were two numbers in the array,
                            //it would be handled in area where k=nums.length-2 and break...
                            //any longer numbers where ascending part is longer than two numbers will enter into area where
                            //isFirstOccurenceAscecndingChain and isFirstOccurenceAscendingChain are processed.
                        }
                        
                        start=String.valueOf(nums[k]);
                        System.out.println("Establishing start: " + start);
                    
                        if (k==nums.length-1)
                        {
                            System.out.println("2Writing Standalone: " + start);
                            sm.add(start);
                        }
                        
                    }
                    counter++; 
                }  //not descending sequence
                else
                {
                    System.out.println("TRACK1");
                    //System.out.println("IN THIS SECTION IF THE NUM[k] and NUM[k+1] ARE ASCENDING SEQUENCE");
                    if (k==nums.length-2)
                    {
                        System.out.println("TRACK2");
                        if (temp!="")
                        {
                            sm.add(temp);
                            System.out.println("9Writing range: " + temp);
                            isFirstOccurenceAscendingChain=false;
                            isFirstOccurenceAscendingChainNoTransition =false;
                        }
                        if (counter==0)
                        {
                            System.out.println("TRACK BACK!!");
                            //descending
                            if (Math.abs(nums[k] - (nums[k+1] + difference)) <epsilon)
                            {
                                start=String.valueOf(nums[k]);
                                end = String.valueOf(nums[k+1]);
                                sm.add(start+"->"+end);
                                System.out.println("7Writing range: " + start + "-> " + end);
                                isFirstOccurenceAscendingChain=false;
                                isFirstOccurenceAscendingChainNoTransition =false;
                            }
                            else   //we know its definitely not descending
                            {
                                System.out.println("TRACK5");
                                end = String.valueOf(nums[k]);
                            
                                if (isFirstOccurenceAscendingChainNoTransition || isFirstOccurenceAscendingChain)
                                {
                                    System.out.println("TRACK6");
                                    if (Math.abs(nums[k] - (nums[k+1] - difference)) <epsilon)
                                    {
                                        end=String.valueOf(nums[k+1]);
                                        sm.add(start+"->"+end);
                                        System.out.println("35Writing range: " + start + "-> " + end); 
                                        hasNotWrittenLastNumber=false;
                                        isFirstOccurenceAscendingChain=false;
                                        isFirstOccurenceAscendingChainNoTransition =false;
                                    }
                                    else
                                    {
                                        System.out.println("TRACK7");
                                        end=String.valueOf(nums[k]);
                                        sm.add(start+"->"+end);
                                        System.out.println("27Writing range: " + start + "-> " + end); 
                                    }
                                }     
                                else  //it is here because neither of the key booleans are set to true...
                                {   System.out.println("TRACK8");
                                
                                    if (temp=="")
                                    {
                                        //                          prev number smaller
                                        System.out.println("TRACK9");
                                        //wide scope
                                        //we know this would be the case for  two ascending numbers only in array  47.3, 47.4 
                                        //but because we are here    (47.3),47.4 it will cause ArrayIndexOutOfBoundsException looking back..
                                        //so perhaps need something before here...
                                        //I do not want to introduce exception handling at all
                                        //we are in this section because k=nums.length-2
                                        //but it can also be k==nums.length-2 for other reason with longer array...
                                        //so need something here that specifically looks at the length of the array
                                        
                                        if (nums.length==2)
                                        {
                                            start=String.valueOf(nums[k]);
                                            end=String.valueOf(nums[k+1]);
                                            sm.add(start+"->"+end);
                                            System.out.println("2678Writing range, only two ascending numbers in array: " + start + "-> " + end);
                                            break;
                                        }
                                        
                                        //prev number descending
                                        if (Math.abs(nums[k] - (nums[k-1] + difference)) <epsilon)
                                        {
                                            System.out.println("TRACK9999");
                                            
                                            
                                            
                                            
                                            //next number is larger         4.0f
                                            if (Math.abs(nums[k] - (nums[k+1] - difference)) <epsilon)
                                            {
                                                 System.out.println("TRACK INSIDE");
                                                //this variable reflects scenario such as where it writes
                                                //2.5->2,4 and  2.4->2.5
                                                //it sets boolean to true
                                                
                                            
                                                if (writtenPrevious)
                                                {
                                                    System.out.println("WRITTEN PREVIOUS-------------------------------------------------------------");
                                                    //start would be at nums[k]
                                                    
                                                    //CRITICAL CHANGE IF SOMETHING GOES WRONG
                                                    start=potentialfurtherAscendingBeyondThisStart;
                                                    //start=String.valueOf(nums[k]);
                                                    
                                                    //we would capture next number in the range
                                                    end=String.valueOf(nums[k+1]);
                                                    sm.add(start+"->"+end);
                                                    System.out.println("6098Writing range: " + start + "-> " + end);
                                                    
                                                }
                                                                 //ST         EN
                                                //3.0f,2.7f,2.5f,(2.4f),2.5f,(4.0f)
                                                
                                                else  //we need to include previous number since state is !writtenPrevious
                                                      //we are still here because of ascending sequence
                                                {
                                                    start=String.valueOf(nums[k-1]);
                                                    end=String.valueOf(nums[k+1]);
                                                    sm.add(start+"->"+end);
                                                    System.out.println("9876Writing range: " + start + "-> " + end);
                                    
                                                    //START IS PREVIOUS NUMBER
                                                    //END IS NEXT NUMBER
                                                    potentialfurtherAscendingBeyondThisStart="";
                                                    potentialfurtherAscendingBeyondThisStart="";
                                                }
                                                
                                                System.out.println("TRACK12");
                                            //3.0f,2.7f,2.5f,2.4f,(2.5f),4.0f
                                            writtenPrevious=false;
                                            
                                            System.out.println("K " + k);
                                            System.out.println(nums.length);
                                            
                                            
                                            
                                            
                                                }
                                                
                                                
                                            //i think I need logic here for situation such as
                                            //3.0f,2.7f,2.5f,2.4f,(2.5f),4.0f
                                            //checking  2.5f with 4.0f
                                            //since it would realise 2.store 2.5f -> 2.4f
                                            //it would need to add this
                                            //it would perform this operation as an else to the below loop
                                            //we have to remember if the chain ended with 
                                            //3.0f,2.7f,2.5f,2.4f,(2.3.f) or //3.0f,2.7f,2.5f,2.4f,(2.6.f)
                                            //it would qualify to be in the else statement...
                                            //we would of course need to pay consideration if 
                                            //3.0f,2.7f,2.5f,2.4f,(2.6.f) since 2.6f becomes standalone
                                            
                                            //prev number is lower and next number is not greater than difference
                                            //3.0f,2.7f,2.5f,2.4f,(2.5f),4.0f
                                            else
                                            {
                                                if (writtenPrevious)
                                                {
                                                    System.out.println("6111using stored start");
                                                    sm.add(potentialfurtherAscendingBeyondThisStart+"->"+potentialfurtherAscendingBeyondThisEnd);
                                                    System.out.println("19761Writing range: " + potentialfurtherAscendingBeyondThisStart+"->"+potentialfurtherAscendingBeyondThisEnd);
                                                    writtenPrevious=false;
                                                    potentialfurtherAscendingBeyondThisStart="";
                                                    potentialfurtherAscendingBeyondThisEnd="";
                                                }
                                                //now we need to write for 2.4->2.5
                                                //3.0f,2.7f,2.5f,2.4f,(2.5f),4.0f
                                                
                                                start=String.valueOf(nums[k-1]);
                                                end=String.valueOf(nums[k]);
                                                    
                                                System.out.println("00000Writing range: " + start+"->"+end);
                                                    //writtenPrevious=false;
                                                    //potentialfurtherAscendingBeyondThisStart="";
                                                    //potentialfurtherAscendingBeyondThisEnd="";
                                                    
                                                    //now we are left with standalone... But I am unsure if it will always be
                                                    //single number left
                                                    //so will approach this with calculation
                                                    
                                                    if (k+1==nums.length-1)
                                                    {
                                                        start=String.valueOf(nums[k+1]);
                                                        sm.add(start);
                                                        System.out.println("0241Writing Standalone: " + start);
                                                        System.out.println("This should be last number");
                                                        break;
                                                        
                                                    }
                                                
                                            }
                                                
                                                
                                                
                                        }
                                        
                                        
                                        
                                        else  //the previously number is not smaller
                                        {
                                                 //next number is not bigger                                           //prev number is not smaller 
                                            if (!(Math.abs(nums[k] - (nums[k+1] - difference)) <epsilon))
                                            {
                                              //EXTREMELY CAREFUL THIS DOES NOT IMPACT ELSEWHERE IN ANY TESTS
                                              System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
                                            start=String.valueOf(nums[k]);
                                            sm.add(start);
                                            System.out.println("009Writing Standalone: " + start);
                                            
                                            start=String.valueOf(nums[k+1]);
                                            sm.add(start);
                                            System.out.println("0089Writing Standalone: " + start);
                                            }
                                            else  //need to assume last two numbers and are ascending sequence....
                                                 //based on analysis of descending descending ascending
                                            {
                                                start=String.valueOf(nums[k]);
                                                end=String.valueOf(nums[k+1]);
                                                sm.add(start+"->"+end);
                                                System.out.println("1992Writing range: " + start + "-> " + end);
                                                isFirstOccurenceAscendingChain=false;
                                                isFirstOccurenceAscendingChainNoTransition=false;
                                            }
                                            
                                        }
                                        combineMerge=true;
                                    }
                                }
                            
                                if (hasNotWrittenLastNumber && !combineMerge)
                                {
                                    start=String.valueOf(nums[k+1]);
                                    System.out.println("4Writing Standalone: " + start);
                                    sm.add(start);
                                    hasNotWrittenLastNumber=false;
                                }
                            }
                        }
                        else   
                        {
                            end=String.valueOf(nums[k]);
                            sm.add(start+"->"+end);
                            System.out.println("3Writing range: " + start + "-> " + end);
                        
                            if ( (Math.abs(nums[k] - (nums[k+1] - difference)) <epsilon)   ||   (Math.abs(nums[k] - (nums[k+1] + difference)) <epsilon))
                            {
                                start=String.valueOf(nums[k]);
                                end=String.valueOf(nums[k+1]);
                                sm.add(start+"->"+end);
                                System.out.println("49Writing range: " + start + "-> " + end);
                                isFirstOccurenceAscendingChain=false;
                                isFirstOccurenceAscendingChainNoTransition =false;
                            }
                            else
                            {
                                start=String.valueOf(nums[k+1]);
                                sm.add(start);
                                System.out.println("599Writing standalone: " + start);
                            }
                        }
                    }
                    else   //k!=nums.length-2
                    {
                        if (Math.abs(nums[k] - (nums[k+1] + difference)) <epsilon)
                        {
                            end=String.valueOf(nums[k+1]);
                        }
                        else
                        {
                            end=String.valueOf(nums[k]);
                        }
                        
                        System.out.println("This is counter at the moment:  " + counter);
                        System.out.println("It is not possible to trigger hasTransition if counter is 0 since can not see transition in opposite direction");
                        
                        if (counter==0)
                        {
                            if(k==0)
                            {
                                //if it is going into descending, we need to make a decision here
                                //if there is something in the store
                                
                                //desc
                                if (Math.abs(nums[k] - (nums[k+1] + difference)) <epsilon)
                                {
                                    System.out.println("0000000000000000000000000000000000000");
                                    if (writtenPrevious)
                                    {
                                    System.out.println("7777using stored start");
                                                        sm.add(potentialfurtherAscendingBeyondThisStart+"->"+end);
                                                        System.out.println("19761Writing range: " + start+"->"+end);
                                                        writtenPrevious=false;
                                                        potentialfurtherAscendingBeyondThisStart="";
                                                        potentialfurtherAscendingBeyondThisEnd="";
                                    }
                                
                                    start=String.valueOf(nums[k]);
                                    counter++;
                                }
                                
                                
                                else
                                {
                                    //ascendency, this is simply used on the basis of consecutive ascending numbers
                                    if (Math.abs(nums[k] - (nums[k+1] - difference)) <epsilon)
                                    {
                                        start=String.valueOf(nums[k]);
                                        end=String.valueOf(nums[k+1]);
                                        
                                        potentialfurtherAscendingBeyondThisStart = start; 
                                        potentialfurtherAscendingBeyondThisEnd = end;
                                        System.out.println("--------------------------------------Stored start -> end: " + start + "->" + end);
                                        
                                        //writtenPrevious=true;
                                        
                                        //sm.add(start+"->"+end);
                                        //System.out.println("58Writing range: " + start + "-> " + end);
                                        isFirstOccurenceAscendingChain=false;
                                        isFirstOccurenceAscendingChainNoTransition =false;
                                    }
                                    else
                                    {
                                        System.out.println("5Writing standalone: " + start);
                                        sm.add(start);
                                    }
                                }
                            }
                            else
                            {
                                if (Math.abs(nums[k] - (nums[k+1] + difference)) <epsilon)
                                {
                                    if (temp=="")
                                    {
                                        if (Math.abs(nums[k] - (nums[k-1] + difference)) <epsilon)
                                        {
                                            backupStart=String.valueOf(nums[k-1]);
                                        }
                                        else
                                        {
                                            backupStart=String.valueOf(nums[k]);
                                        }
                                    
                                        temp=backupStart+"->"+end;
                                        hasTransition=false;
                                        System.out.println(" 1hasTransition set back to false");
                                    }
                                    else
                                    {
                                        end=String.valueOf(nums[k+1]);
                                        temp=backupStart+"->"+end;
                                        hasTransition=false;
                                        System.out.println(" 2hasTransition set back to false");
                                    }
                                    System.out.println("8Storing range: " + temp);
                                }
                                else
                                {
                                    if(temp!="")
                                    {
                                        sm.add(temp);
                                        System.out.println("8Writing range: " + temp);
                                        temp="";
                                        backupStart="";
                                        isFirstOccurenceAscendingChain=false;
                                        isFirstOccurenceAscendingChainNoTransition =false;
                                    }
                                    else
                                    {
                                        
                    if ((Math.abs(nums[k] - (nums[k-1] + difference)) <epsilon) ||   (Math.abs(nums[k] - (nums[k+1] - difference)) <epsilon))
                                        {
                                            end = String.valueOf(nums[k]);
                                            
                                            //ascending sequence
                                            if  (Math.abs(nums[k] - (nums[k+1] - difference))<epsilon)
                                            {
                                                if (!isFirstOccurenceAscendingChainNoTransition)
                                                {
                                                    start=String.valueOf(nums[k]);
                                                    
                                                    isFirstOccurenceAscendingChainNoTransition=true;
                                                }
                if ((Math.abs(nums[k] - (nums[k-1] + difference)) <epsilon) &&   (Math.abs(nums[k] - (nums[k+1] - difference))<epsilon))
                                                    {
                                                        if (!isFirstOccurenceAscendingChain)
                                                        {
                                                            start=String.valueOf(nums[k-1]);
                                                            
                                                            isFirstOccurenceAscendingChain=true;
                                                        }
                                                    }
                                            }  // its here because sequence is not ascending  (3.6 with 40.0)
                                            else
                                            {
                                                if (isFirstOccurenceAscendingChainNoTransition || isFirstOccurenceAscendingChain)
                                                {
                                                    
                                                    if (!potentialfurtherAscendingBeyondThisStart.equals("") && !(potentialfurtherAscendingBeyondThisEnd.equals("")))
                                                    {
                                                        System.out.println("using stored start");
                                                        sm.add(potentialfurtherAscendingBeyondThisStart+"->"+end);
                                                        System.out.println("19761Writing range: " + start+"->"+end);
                                                    }
                                                    else
                                                    {
                                                        sm.add(start+"->"+end);
                                                        System.out.println("1541Writing range: " + start+"->"+end);
                                                    }
                                                    
                                                    potentialfurtherAscendingBeyondThisEnd="";
                                                    potentialfurtherAscendingBeyondThisStart="";
                                                    
                                        
                                                isFirstOccurenceAscendingChain=false;
                                                isFirstOccurenceAscendingChainNoTransition=false;
                                                isFirstOccurenceAscendingChain=false;
                                                isFirstOccurenceAscendingChainNoTransition =false;
                                                }
                                            }
                                        }
                                        else  //it is here because one before is not smaller by difference
                                              // or the one in front is not bigger by difference
                                              //ie not an ascending sequence
                                        {
                                                start = String.valueOf(nums[k]);
                                            sm.add(start);
                                            System.out.println("6Writing Standalone: " + start);
                                            isFirstOccurenceAscendingChain=false;
                                            isFirstOccurenceAscendingChainNoTransition=false;
                                            
                                        }
                                    }  
                                }
                            }
                        }
                        else    //counter!=0              3.5, (3.4),  3.5   //we can see there is not a transition here since we are accustomed to seeing 
                                                          // the following sequence would qualify in here   3.3, 3.4, 3.3
                                                          //So we must handle the additional logic of the sequence 3.5, (3.4), 3.5 in area of code
                                                          //where 3.4f makes decision with next number.. this is in section 2writing range
                                                          //whatever happens, it has to remember to place  3.5f->3.4f first
                                                          //3.5f,(3.4f),3.5f,3.4f
                        {                                  
                                            //prev number is less                                         //next number is less         
                            if ((Math.abs(nums[k] - (nums[k-1] + difference)) <epsilon)  && (Math.abs(nums[k] - (nums[k+1] + difference)) <epsilon))
                            {
                                end=String.valueOf(nums[k]);
                                sm.add(backupStart+"->"+end);
                                System.out.println("10Writing range: " + backupStart+"->"+end);
                                hasTransition=true;
                                System.out.println(" 12hasTransition set to true");
                                transitionNumber=String.valueOf(nums[k]);
                                isFirstOccurenceAscendingChain=false;
                                isFirstOccurenceAscendingChainNoTransition =false;
                            }
                            if (!hasTransition)
                            {
                                if (temp!="")
                                {
                                    end=String.valueOf(nums[k+1]);
                                    sm.add(start+"->"+end);
                                }
                                else
                                {
                                    //it would be processing these at this point. It is also due to counter!=0
                                    //since it has performed (3.5f,3.4f)
                                    //We can see above that it states !hasTransition.
                                    //we can see there is transition but because the transition has happened on second number.
                                    //However looking at code above, it enters hasTransition=true when the counter!=0
                                    //so unfortunately this leaves an issue since (3.5f),3.4f is still when counter ==0
                                    //I will verify this also with output of the counter value
                                    
                                    System.out.println("COUNTER VALUE: " + counter);
                                    
                                    //3.5f,(3.4f,3.5f),3.4f 
                                    
                                    //this is going to be massively improvised
                                    //And if my chatGPT test case begins to fail, I will visit here to undo this change
                                    //basically to undo the change, I will need to remove the if
                                    //and change the else with the if
                                    //if previous number is greater, we need to write start=nums[k] and end = nums[k-1]
                                    //3.5f, (3.4f), 3.5f, 3.4f 
                                    
                                    //prev number greater                                                    //next number greater                         
                                    if ((Math.abs(nums[k] - (nums[k-1] - difference)) <epsilon) && (Math.abs(nums[k] - (nums[k+1] - difference)) <epsilon))
                                    {
                                        //I will now write the existing start ->  end  (3.5f, 3.4f)
                                        System.out.println("3121Writing range: " + start + "-> " + end);
                                        sm.add(start+"->"+end);
                                        end=String.valueOf(nums[k+1]);
                                        start=String.valueOf(nums[k]);
                                        
                                        //perhaps need to store value in variable start->end
                                        //in event that next k is greater again
                                        //3.5f,3.4f,3.5f,(3.6f),32.1f,32.2f
                                        //otherwise it will write 3.4->3.5
                                        //3.4->3.6
                                        //the chain could go on ascending long time, so no point checking for difference
                                        //such as [k+2].......
                                        
                                        potentialfurtherAscendingBeyondThisStart = start; 
                                        potentialfurtherAscendingBeyondThisEnd = end;
                                        System.out.println("--------------------------------------Stored start -> end: " + start + "->" + end);
                                        //System.out.println("9846Writing range: " + start + "-> " + end);
                                        //sm.add(start+"->"+end);
                                        
                                        writtenPrevious=true;
                                        System.out.println("value of next k: "+ (k+1));
                                        System.out.println("last index array: "+ (nums.length-1));
                                        
                                        //we know we have included k+1 as the end.
                                        //so if there is one number left in the array, we can set a flag
                                        if (((nums.length-1)-(k+1))==1)
                                        {
                                            includeStandalone=true;
                                        }
                                    }
                                    else
                                    {
                                    System.out.println("2Writing range: " + start + "-> " + end);
                                    
                                    sm.add(start+"->"+end);
                                    }
                                    
                                    isFirstOccurenceAscendingChain=false;
                                    isFirstOccurenceAscendingChainNoTransition =false;
                                    
                                }
                            }
                            counter=0;
                            temp="";
                            backupStart="";
                            hasTransition=false;
                            System.out.println(" 3hasTransition set back to false");
                        }
                    }
                }
            }
        }
            return sm;
    }
}