Petraeus leaving Army after 37 years to head CIA