Nonlinear optical response of a two-dimensional atomic crystal