added the code to calculate the no of triangles possible in the array