from typing import List
class Solution:
  def longestMountain(self, arr: List[int]) -> int:
    res = 0
    i = 1
    while i < len(arr):
      while i < len(arr) and arr[i-1] == arr[i]:
        i += 1
      
      up = 0
      while i < len(arr) and arr[i-1] < arr[i]:
        up += 1
        i += 1
      down = 0
      while i < len(arr) and arr[i-1] > arr[i]:
        down += 1
        i += 1
        
      if up and down:
        res = max(up+down+1, res)
    return res