Finite element analysis of primal and dual variational formulations of semicoercive elliptic problems with nonhomogeneous obstacles on the boundary