Zero-padding the middle of a signal I sample a signal at a certain frequency for a finite amount of time to get a sequence $$(x_n)_{n=1}^N = (x_1, x_2, ... , x_N)$$

with the intention of analyzing its power spectral density by calculating its DFT.

I decide that the tail end of the sequence shouldn't be analyzed (that is, I want to discard all $x_n$ for $n\gt a$ for some $a\leq N$), but I want the DFT to have the same number of samples (in this case, $N$ samples).

One approach would be to truncate the sequence at $x_a$, remove the mean, apply a Hamming window to this truncated sequence, pad the truncated sequence with $N-a$ zeroes, and then calculate its DFT.

Question: Let's say that the section I don't want to analyze is an interval in the middle of the sequence. How do I calculate the DFT of this and make sure the DFT has $N$ samples? Should I remove the mean, apply two Hamming windows (one each on each section I don't want to discard), set the elements in the middle that I want to discard to zero, and calculate the DFT?

This is related to my other question here.
If there's a region in the middle of the sequence that you want to discard, you can't just set those samples to zero and compute the DFT, because the DFT would reflect the fact that your sequence suddenly jumps to the value zero, and then suddenly jumps back again to non-zero values. So the zero values would significantly contribute to the result of the DFT, which is almost the opposite of what you want to achieve.

What you should do is consider the two relevant parts at the beginning and at the end as two realizations of the underlying process, and compute two DFTs, which can then be averaged, just like in Bartlett's method. Of course, each sub-sequence can (and should) be windowed and zero-padded before computing the DFT.