I tried the question but im getting wrong output

Given an array of heights of N buildings in a row. You can start from any building and jump to the adjacent right building till the height of building to the right is less than or equal to the height of your current building. Find the maximum number of jumps you can make. Input First line of input contains a single integer N. Second line of input contains N integers, denoting the array height.

Constraints: 1 <= N <= 100000 1 <= height[i] <= 1000000000 Output Print the maximum number of jumps you can make.the program i tried

class Main {
    public static void main (String[] args) {
                      // Your code here
                 Scanner sc = new Scanner(System.in);
                      int n = sc.nextInt();
                      int[]a = new int[n];
                      for(int i = 0; i<n; i++){
                          a[i] = sc.nextInt();
                      }
                      int count=1;
                      int max = a[0];
                      for(int i = 1; i<n; i++){
                          if(a[i] > max)
                          {
                              count++;
                              max = a[i];
                          }
                      }
                      System.out.println(count);

Check it,

public class Main {
        public static void main (String[] args) {
                // Your code here
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();

                int previous_building_height = sc.nextInt();
                int current_building_height = 0;
                int count =0, max_count =0;

                for(int i = 1; i<n; i++){
                        current_building_height = sc.nextInt();
                        if(current_building_height >= previous_building_height){
                                count ++;
                        }else{
                                max_count = max_count < count ? count : max_count;
                                count =0;
                        }
                        previous_building_height = current_building_height;
                }

                max_count = max_count < count ? count : max_count;
                System.out.println(max_count);

        }
}

You don't need to save all the buildings height. At a given building, we just need to know the previous building height. If the previous building is shorter than the current you can jump. Else, if your jumps counter has the highest value, you save it. Next, you restart your jumps counter.

Also, try to give a better title to your question.