If there are 27 posts, then there are (n - 1) total spaces between the posts . . . 27 - 1 = 26 total spaces (since there has to be a post at each end of the line)
Here's an example of 7 posts equally spaced . . . so you can see there are one less spaces between posts than there are posts (i.e. 6 total spaces between 7 posts) . . .
[] . . . [] . . . [] . . . [] . . . [] . . . [] . . . []
27 posts = 27*(10cm) = 270 cm = 2.7m
26 spaces = 26*(30m) = 780 m
Length of Fence = L = 780m + 2.7m = 782.7m