Why was -1 added?

why did he do -1 in this statement?
int idx = upper_bound(coins,coins+n,money)-1-coins;