Given an equilateral triangle with side length N divided into a triangular grid of triangles with side length 1, count the total number of triangles present in the grid. For example, if N is 4:
/\
/__\
/\ /\
/__\/__\
/\ /\ /\
/__\/__\/__\
/\ /\ /\ /\
/__\/__\/__\/__\
Here there are ten rightsideup and six upsidedown triangles with a side length of 1, six rightsideup and one upsidedown triangles with a side length of 2, three rightsideup triangles with a side length of 3, and one rightsideup triangle with a side length of 4. The total number of triangles is 27.
