To purchase a book for each student, Sally needs: 30 x $12 = $<<30*12=360>>360.
She thus needs to pay $360 - $320 = $<<360-320=40>>40 out of pocket.
#### 40