Periodic solutions of second order nonautonomous systems with the potentials changing sign