Check engine can be an expensive rabbit hole. Change all spark plugs and while the intake is removed from th engine: INSPECT FUEL INJECTORS.
Many times these sensors (such as cam position sensor A) read many items and as they age misreport.
If I had a nickle for each time a bad fuel injector...