In a remarkable work [Phys. Rev. A 86 022316 (2012)], Howard and Vala introduced a qudit version of the qubit T-gate (i.e., π/8-gate) for any prime dimensional system. This non-Clifford gate is a key ingredient of the paradigm ‘Clifford +T’, which are widely employed in the stabilizer formalism of universal and fault-tolerant quantum computation. Considering the applications and significance of the T-gate, it is desirable to characterize it from various angles. Here we prove that in any prime dimensional system, the Howard-Vala T-gate is optimal, among all diagonal gates, for generating magic resources from stabilizer states when the magic is quantified via the L 1-norm of characteristic functions (Fourier transforms) of quantum states. The quadratic Gaussian sum in number theory plays a key role in establishing this optimality. This highlights an extreme feature of the Howard-Vala T-gate. We further reveal an intrinsic relation between the Howard-Vala T-gate and the Watson-Campbell-Anwar-Browne T-gate [Phys. Rev. A 92 022312 (2015)] for any prime dimensional system.