Failed and/or aftermarket timing belt tensioner
1. Install all new Subaru timing belt, tensioner, and lower cogged idler. Or just get an entire AISIN timing kit (OEM parts).
Or, if you're unlucky and the valves were bent:
2. Install used heads if the valves are bent. No need for a valve job, just resurface the heads and install with Subaru gaskets.
If the engine does happen to be toast - I wouldn't get that turbo for a variety of reasons. The install would be insanely complicated, best facillated with an aftermarket controller due to the cross generational aspect...and the unknown history and risk of a 15 year old turbo engine leaves a lot to be desired.