Energy spectrum of interplanetary magnetic flux ropes and its connection with solar activity