/*
Online Java is a quick and easy tool that helps you to build, compile, test your programs
online.
*/

public class Main
{
    public static void main(String[] args) 
    {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        int numArray [] = new int[]{3,4,9,6,1};
        int length = numArray.length;
        Elements el = new Elements(length, numArray);
    }
}

class Test
{
    public Test()
    {
        System.out.println("dsadas");
    }
}

class Elements
{
    int length;
    int numArray[] = new int[length];
    int count;
    
    public Elements()
    {
    }
    
    public Elements(int length, int numArray[])
    {
        this.length=length;
        this.numArray=numArray;
        System.out.println("These are the elements:");
        
        for (int elem:numArray)
        {
            System.out.println(elem);
        }
        
        for (int i=0; i<length;i++)
        {
            if (i==length-1)
            {
                setElement(0,i);
                break;
            }
            count=0;
            
            for (int j=i+1; j<length; j++)
            {
                if (numArray[j]<numArray[i])
                {
                    count++;
                }
            }
            
            setElement(count,i);
        }
    }
    
    public void setElement(int smallerElements, int num)
    {
        boolean flag=false;
        
        if (smallerElements==0)
        {
            System.out.println("There are no" + " smaller elements to the right of " + numArray[num]);
            flag=true;
        }
        
        if (!flag)
        {
            System.out.println("There is " + smallerElements + " smaller element to the right of " +
            numArray[num]);
            flag=false;
        }
    }
}