Density-functional theory of surfacelike elasticity of nematic liquid crystals