In one embodiment, a first magnetoresistive effect element, a current supply unit and a detecting unit is provided. The first magnetoresistive effect element is provided between first and second electrodes and along a first direction which is a current flowing direction between the first and the second electrode. The first magnetoresistive effect element includes first and second magnetic layers and a first intermediate layer provided between the first and the second magnetic layer and along the first direction and a second direction orthogonal to the first direction. The current supply unit is connected to the first and the second electrode and can supply an alternating current. The detecting unit detects a second harmonic component of an alternating current voltage signal outputted from the first magnetoresistive effect element. A length of the first magnetoresistive effect element in the first direction is larger than a length in the second direction.