Making sure none of the wires are shorting out on anything, you want to find what wires coming out of that gray connector plug has 12Volts on it when your key is in the ON or ACC position, and 0 volts when in the OFF position. This allows your amp to turn on/off with the car and not drain your battery down. If you disconnect the battery, then you wont have any voltage for testing which wire you need. On a 2004 cavalier it is pink for the Accessory on signal, on the aftermarket-radio end of the gray plug its probably red, or maybe blue or blue with a white stripe (but the two later are usually outputs from the aftermarket head unit to amps, while the first is what triggers the headunit to turn on). Once you find this wire you want to attach it with the lone blue wire that disappears into the back of the dash with the RCA wires. Do this by stripping back the insulation an inch or so and twist the two wires together. Then fold the twist over on itself and tape it up for a cheap-yet-somewhat-reliable-connection.
If you want to unhook your battery (ground first) then do so after you discover what wire you need. It's safer that way. 12 volts isn't going to hurt anyone with dry hands. If you don't unhook the battery just be sure to leave the key out of the ignition when you're stripping the wires back.