# [Wolfram Language (Mathematica)], 24 bytes -3 bytes thanks to [@att](https://codegolf.stackexchange.com/users/81203/att). Max@#-Tr[Tr/@(1^#)/2-1]& [Try it online!][TIO-lm9zi7oh] [Wolfram Language (Mathematica)]: https://www.wolfram.com/wolframscript/ [TIO-lm9zi7oh]: https://tio.run/##vY5LCoMwEIavMhiQFiI2MfGxaPEChS7ciYVQKnVhF@KiIJ49zbPRC3QRmG/mn/kyivn1HMU8PITs4QzyKj41Spqpbaa0PpA7OqY0IV0sb9PwnluEIYLkAhGGvkVdBzGkNSzLQjBQDNmKQZcZBuZK6krqurr26ZBiGEoMPOzkjmysUA1NzFOpiZuYoc1VHoQ2sPlUvvuX2qyCQ/kLN6sMZc5oyft52LOlmRn/X412j5zUI97hQKXodq5s5BfQkOmmTzDboM7mmXsmuwueTGJd5Rc "Wolfram Language (Mathematica) – Try It Online"