3(n-1)^2+2(n-1) looks about right, which is 3n^2-6n+3 +2n-2=3n^2-4n+1
tilt your head 45 degrees, there are (n-1)^2 identical patterns of "7|", that is two edges of a square and a diagonal, so that's the first part of the formula. the second bit comes from counting all that's left over.