'''simple docstring'''

def  _lowerCAmelCase				(				__a      )  ->      tuple[int, int]:
     '''simple docstring'''







     if len(__a      ) == 1:
          return a[0], a[0]
     else:
          # split A into half.
          _UpperCamelCase  :Tuple       =a[: len(__a      ) // 2]
          _UpperCamelCase  :List[Any]       =a[len(__a      ) // 2 :]

          # 2 sub problems, 1/2 of original size.
          _UpperCamelCase       ,      _UpperCamelCase  :Optional[int]       =max_difference(__a      )
          _UpperCamelCase       ,      _UpperCamelCase  :Dict       =max_difference(__a      )

          # get min of first and max of second
          # linear time
          _UpperCamelCase  :Any       =min(__a      )
          _UpperCamelCase  :List[Any]       =max(__a      )

          # 3 cases, either (small1, big1),
          # (min_first, max_second), (small2, big2)
          # constant comparisons
          if biga - smalla > max_second - min_first and biga - smalla > biga - smalla:
               return smalla, biga
          elif biga - smalla > max_second - min_first:
               return smalla, biga
          else:
               return min_first, max_second


if __name__ == "__main__":
      import doctest

      doctest.testmod()



import os







def 	A (		):
     UpperCAmelCase    :					Any			=      os.path.dirname(os.path.realpath(A__			)			)
     UpperCAmelCase    :					Optional[int]			=      os.path.join(A__		,		"triangle.txt"			)

     with open(A__			) as f:
          UpperCAmelCase    :					Union[str, Any]			=      f.readlines()

     UpperCAmelCase    :					List[str]			=      [[int(A__			) for y in x.rstrip("\r\n"			).split(" "			)] for x in triangle]

     for i in range(1		,		len(A__			)			):
          for j in range(len(a[i]			)			):
               UpperCAmelCase    :					List[Any]			=      a[i - 1][j] if j != len(a[i - 1]			) else 0
               UpperCAmelCase    :					Optional[int]			=      a[i - 1][j - 1] if j > 0 else 0
               a[i][j] += max(A__		,		A__			)
     return max(a[-1]			)


if __name__ == "__main__":
      print(solution())



