Layer-number-dependent work function of MoS2 nanoflakes