According to one embodiment, a sensor includes a plurality of light-emitting elements, and a light receiving element. The light-emitting elements are arranged along a first direction and a second direction, the second direction intersecting the first direction. At least a portion of light emitted from each of the light-emitting elements is incident on the light receiving element. The light-emitting elements do not overlap the light receiving element in a third direction, the third direction being perpendicular to the first direction and the second direction. The light-emitting elements include a first light-emitting element and a second light-emitting element. A position of the second light-emitting element in a plane is between a position of the first light-emitting element in the plane and a position of the light receiving element in the plane. The plane includes the first direction and the second direction.