Let $\mathfrak{S}_n$ be the permutation group on $\{1,\dots,n\}$. Given $\pi=\pi_1\pi_2\dots\pi_n\in\mathfrak{S}_n$, its major index statistic is denoted **maj**$(\pi)$. Define the polynomials
$$Q_{n,k}(x):=\sum_{\pi\in\mathfrak{S}_n}x^{\text{maj}(\pi)+\pi_n+\pi_{n-1}+\cdots+\pi_{n-k}}.$$

**EDIT.**

**maj** can be replaced by the inversion number **inv** without affecting $Q$. This is true due to the work of Foata and Schutzenberger on the equi-distribution of the two statistics (as multisets). However, Fedor's question made me reflect again. Is it still true that
$\{\text{maj$(\pi)+\pi_n+\dots+\pi_{n-k}$}: \pi\in\mathfrak{S}_n\}$ and
$\{\text{inv$(\pi)+\pi_n+\dots+\pi_{n-k}$}: \pi\in\mathfrak{S}_n\}$ are equi-distributed? If yes, then Fedor's answer is complete.

CLAIM.$\,\,$ Experiment supports that, for each $n$ and $k$, we have $$Q_{n,k}(x) =\binom{n}{k+1} x^{(k+1)n-\binom{k+1}2}\prod_{i=0}^k\left(1+x+\cdots+x^i\right)\prod_{j=0}^{n-k-2}\left(1+x+\cdots+x^j\right).$$ Any proof?

The above exploration was motivated by this paper.