there 3n pile coin vary size friend pile coin followsIn step choose 3 pile coin necessarily consecutiveof choice Alice pick pile maximum number coinsyou pick pile maximum number coinsYour friend Bob pick pilerepeat pile coinsGiven array integer piles pilesi number coin ith pileReturn maximum number coin Example 1input pile 241278output 9explanation Choose triplet 2 7 8 Alice Pick pile 8 coin pile 7 coin Bob onechoose triplet 1 2 4 Alice Pick pile 4 coin pile 2 coin Bob onethe maximum number coin 7 2 9On hand choose arrangement 1 2 8 2 4 7 2 4 6 coin optimalexample 2input pile 245output 4example 3input pile 987651234output 18 Constraints3 pileslength 105pileslength 3 01 pilesi 104