Count the number of triangles
R, 62 52 40 34 bytes



sum(c(1,1,-1)%*%combn(scan(),3)&gt;0)


Try it online!

Port of Luis Mendo's Octave solution

Since a&lt;=b&lt;=c, the triangle condition is equivalent to a+b-c&gt;0. The a+b-c is succinctly captured by the matrix product [1,1,-1] * X, where X is the 3-combinations of the input array.

There were a lot of suggestions for improvements made by 3 different people in the comments:


Robert S. for suggesting scan.
Robin Ryder for suggesting improvements to the triangle inequality and this odd one which requires the input to be in descending order (which just goes to show how important a flexible input format is).
and finally Nick Kennedy for the following:


R, 40 bytes



y=combn(scan(),3);sum(y[3,]&lt;y[1,]+y[2,])


Try it online!