Count Good Triplets in an Array