  Let $p$ be prime number and $K$ be a $p$-adic field. We systematically
compute the higher $\mathrm{Ext}$-groups between locally analytic generalized
Steinberg representations (LAGS for short) of $\mathrm{GL}_n(K)$ via a new
combinatorial treatment of some spectral sequences arising from the so-called
Tits complex. Such spectral sequences degenerate at the second page and each
$\mathrm{Ext}$-group admits a canonical filtration whose graded pieces are
terms in the second page of the corresponding spectral sequence. For each pair
of LAGS, we are particularly interested their $\mathrm{Ext}$-groups in the
bottom two non-vanishing degrees. We write down an explicit basis for each
graded piece (under the canonical filtration) of such an $\mathrm{Ext}$-group,
and then describe the cup product maps between such $\mathrm{Ext}$-groups using
these bases. As an application, we generalize Breuil's $\mathscr{L}$-invariants
for $\mathrm{GL}_2(\mathbb{Q}_p)$ and Schraen's higher $\mathscr{L}$-invariants
for $\mathrm{GL}_3(\mathbb{Q}_p)$ to $\mathrm{GL}_n(K)$. Along the way, we also
establish a generalization of Bernstein--Zelevinsky geometric lemma to
admissible locally analytic representations constructed by Orlik--Strauch,
generalizing a result in Schraen's thesis for $\mathrm{GL}_3(\mathbb{Q}_p)$.
