Answer:
Here we have 6 rails between each pair of posts.
If the extremes are not conected, and we have 27 posts, then we must have 27 - 2 pairs of posts. Because the posts at the ends do not have any other post to form a pair, then we have 25 pairs.
and for each pair we have 6 rails, so we have 25*6 = 150 rails
If the ends are conected, like in a square, then the first post and the 27th post does make a pair, so in this case we have a pair more than in the previous case, so we have:
27 - 1 = 26 pairs, and the number of rails is:
26*6 = 156 rails