I noticed that some of the accepted codes for this problem are incorrect. You can take any accepted code and test with the case: t=1, n=6, a[i]:{8, 1, 3, 4, 6, 8}. When running manually, the result should be 38, but some codes still get accepted even though they are wrong. I’ve tested a few codes, and their results were 46, 246, and so on.