  For any limit ordinal $\lambda$, we construct a linear order $L_\lambda$
whose Scott complexity is $\Sigma_{\lambda+1}$. This completes the
classification of the possible Scott sentence complexities of linear orderings.
Previously, there was only one known construction of any structure (of any
signature) with Scott complexity $\Sigma_{\lambda+1}$, and our construction
gives new examples, e.g., rigid structures, of this complexity.
  Moreover, we can construct the linear orders $L_\lambda$ so that not only
does $L_\lambda$ have Scott complexity $\Sigma_{\lambda+1}$, but there are
continuum-many structures $M \equiv_\lambda L_\lambda$ and all such structures
also have Scott complexity $\Sigma_{\lambda+1}$. In contrast, we demonstrate
that there is no structure (of any signature) with Scott complexity
$\Pi_{\lambda+1}$ that is only $\lambda$-equivalent to structures with Scott
complexity $\Pi_{\lambda+1}$.
  Our construction is based on functions $f \colon \mathbb{Z}\to \mathbb{N}\cup
\{\infty\}$ which are almost periodic but not periodic, such as those arising
from shifts of the $p$-adic valuations.
