4.0 is the iOS, 4G is the phone

3g, and 3gs can update to the new 4.0 iOS from iTunes, which has not long been released.

3gs does the job, just see what you can haggle on the new 4G, as if you're new to iPhones, or this is your first one, might as well go for the "best" and most current.