For a prime number \(p\ge 3\) we let \(G(p)=\left\langle \overline{x}\right\rangle \) denote the group of reduced residue classes modulo p and we let \(\widehat{G}(p)=\left\{ \chi _{0},\chi _{1},\ldots ,\chi _{p-2}\right\} \) denote the group of Dirichlet characters modulo p. Let l and \(\nu _l\) be integers such that \(\gcd (p,l)=1\) and \(\overline{l}=\overline{x}^{\nu _l}\) . The main purpose of this paper is to present an explicit formula for the sum: \(\begin{aligned} \sum _{a=0}^{p-2}|B_1(\chi _a)|^2\cos \left( \dfrac{2\pi a\nu _l}{p-1}\right) , \end{aligned}\) where \(B_m(\chi )\) \((m\ge 0)\) are the generalized Bernoulli numbers associated with \(\chi \) .