You have three options.
1. Cut that top piece of pipe as straight as possible add a coupling and extend the piece to the desired height.
2. Cut the p trap and install a new one.
3. You can attempt to cape the piece out. This is accomplished by making several cuts inside of the pipe with a hack saw and with a chisel you try to "pry'' it off. Option 1 is probably the best way to go.