title: Remove Minimum Elements Either Side 2Min Max
signature: def remove_minimum_elements_either_side_2min_max(arr, n):
test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, n, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([32, 50, 66, 73, 76, 87], 5, 1)
      print(f"TEST-0...{result}")
  
      result = driver([68, 74, 16, 40, 6, -44, -36, 94, 6, -24, -4, -58, -16, 24], 11, 9)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11, 9)
      print(f"TEST-2...{result}")
  
      result = driver([91, 22], 1, 0)
      print(f"TEST-3...{result}")
  
      result = driver([-84, -80, -78, -76, -58, -54, -52, -48, -42, -42, -40, -38, -34, -32, -28, -24, -6, 2, 2, 4, 10, 14, 16, 18, 26, 26, 36, 40, 50, 52, 62, 64, 72, 74, 84, 90, 94, 96, 98], 35, 28)
      print(f"TEST-4...{result}")
  
      result = driver([1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1], 13, 10)
      print(f"TEST-5...{result}")
  
      result = driver([10, 19, 25, 29, 32, 37, 40, 43, 43, 44, 46, 51, 51, 54, 56, 58, 63, 79, 83, 86, 87, 97, 97], 11, 2)
      print(f"TEST-6...{result}")
  
      result = driver([-48, -28, 10, 30, 78, -72, 78, 52, -52, -68, 56, 42, 8, -42, 16, -56, 2, -90, -26, -28, -56, -2, 80, -50, 98, -64, -96, 10, -10, 44, 98, -48, -88, 42, 30, 24, 38, -26, -52, -12, 0, 34, -82, -80, 0, -84, -20], 25, 23)
      print(f"TEST-7...{result}")
  
      result = driver([0, 0, 1, 1, 1, 1, 1, 1], 6, 2)
      print(f"TEST-8...{result}")
  
      result = driver([25, 82], 1, 0)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
source_py: def remove_minimum_elements_either_side_2min_max(arr, n):
      longest_start = (- 1)
      longest_end = 0
      for start in range(n):
          min = sys.maxsize
          max = (- sys.maxsize)
          for end in range(start, n):
              val = arr[end]
              if (val < min):
                  min = val
              if (val > max):
                  max = val
              if ((2 * min) <= max):
                  break
              if (((end - start) > (longest_end - longest_start)) or (longest_start == (- 1))):
                  longest_start = start
                  longest_end = end
      if (longest_start == (- 1)):
          return n
      return (n - ((longest_end - longest_start) + 1))
source_cpp: int remove_minimum_elements_either_side_2min_max(vector<int> arr, int n) {
    int longest_start = - 1, longest_end = 0;
    for ( int start = 0;
    start < n;
    start ++ ) {
      int min = INT_MAX, max = INT_MIN;
      for ( int end = start;
      end < n;
      end ++ ) {
        int val = arr [ end ];
        if ( val < min ) min = val;
        if ( val > max ) max = val;
        if ( 2 * min <= max ) break;
        if ( end - start > longest_end - longest_start || longest_start == - 1 ) {
          longest_start = start;
          longest_end = end;
        }
      }
    }
    if ( longest_start == - 1 ) return n;
    return ( n - ( longest_end - longest_start + 1 ) );
  }