The function $p:\{a_{1},\ldots a_{n}\}\to\sum_{i=1}^{n}\cos\alpha_{i}$,
for $\lVert a_{i}\rVert=1$, seems to be a measure of proximity to
the given standard orthonormal basis $\{e_{1},\ldots e_{n}\}$: $1\leq p\leq n$.
What is the $\max_{\{a_{1},\ldots a_{n}\}\subset H^{n-1}}p$? (Spoiler:
it's $\sqrt{n(n-1)}$). Let's first try to put the hyperplane $H^{n-1}$
"flat" on the $span(e_{1},\ldots e_{n-1})$ with the $e_{n}$
being its unit normal. We're free to choose the best alignment possible for $a_{i}=e_{i}$, $1\leq i\leq n-1$. It doesn't matter in this case but let's choose $a_{n}=\frac{1}{\sqrt{n-1}}\sum_{i=1}^{n-1}e_{i}$ for symmetry reasons. We have achieved a respectable $p_{0}=n-1$.
However, $p$ can be made slightly larger if we tilt the hyperplane
"pulling" the unlucky $a_{n}$ (chosen as above) towards $e_{n}$ by an
angle $\beta$. For example, in 2D, we'd get a better (the maximum actually)
$p_{\beta}=\sqrt{2}>1=p_{0}$ by aligning $a_{1}$and $a_{2}$ along
$\beta=45{}^{\circ}$ between $e_{1}$ and $e_{2}$.
Let's do this. It's a simple but cumbersome trigonometric and vector
arithmetic, followed by differentiation to find the best optimal angle.
I hope someone can write this in a matrix algebraic-way or even fancier.
Again, for symmetry reasons all $\alpha_{i}=\alpha$, $1\leq i\leq n-1$,
so we have
$$
p_{\beta}=(n-1)\cos\alpha+\sin\beta
$$
I will be skipping some details now, adding them back by request possibly
with a diagram showing the triangles. The best $\cos\alpha$ we could
get from orthogonally projecting now detached $e_{1},\ldots$ back onto
the tilted hyperplane to find the best $a_{1},\ldots$: $\langle e_{1},N_{\beta}\rangle=cos(\tfrac{\pi}{2}+\alpha)=-\sin\alpha$.
We therefore need to find the unit normal to the hyperplane,
$$
N_{\beta}=\frac{e_{n}-\tan\beta\cdot a_{n}}{\sqrt{1+tan^{2}\beta}}
$$
After some manipulations we'll get
$$
\cos\alpha=\sqrt{1-\frac{\sin^{2}\beta}{n-1}}
$$
Now let $x=\sin\beta$ and we have
$$
p(x)=(n-1)\sqrt{1-\frac{x^{2}}{n-1}}+x
$$
Differentiating by $x$ and solving $p^{\prime}(x)=0$ we find the
best tilt angle $x=\sin\beta=\sqrt{\frac{n-1}{n}}=\cos\alpha$ (so it turns out all the $n$ angles are in fact equal $\alpha_1=\ldots=\alpha_n$ as they should be) and the largest
possible by construction
$$
p=\sqrt{n(n-1)}.
$$
Any value of $p$ larger than that would have to come from a $\{a_{1},\ldots a_{n}\}$
not constrained to a hyperplane being therefore a linear independent set.