Teen sentenced to 40 years