For a school bake sale, students sold 312 cupcakes. They earned $670.80 from selling cupcakes. What was the cost of each cupcake?