Array sum for triplets