Imac boots halfway then shuts off
Went to go start my Imac today and it was taking a very long time to boot. It would get to the end of the loading bar then stop and freeze on the boot screen. Turned off the computer then tried again and now it goes halfway then shuts off. I've tried starting in safe mode but it still shuts off halfway. Can someone please help me? I've never upgraded anything, or upgraded the software. I bought it used with El Capitan.
Imac specs: Apple 20inch, Core 2 duo, 2.66GHz, 4GB RAM, 320GB Hard Drive.
MacBook Pro, I dont know whats going on...