It's mostly the BOS-MAD flight $850. From
https://matrix.itasoftware.com
Fare Construction (can be useful to travel agents)
BOS IB MAD Q14.00 M 2050.00INWTC4S3 NUC 2064.00 END ROE 1.00 XT 21.10US 5.60AY 850.00YQ 4.50XF BOS4.50
The NRT-BOS flight is around $355.
Fare Construction (can be useful to travel agents)
TYO AA BOS M 4945.67CNX70ZN2 NUC 4945.67 END ROE 136.078400 XT 530OI 2130SW 1000TK 860YC 920XY 500XA 2760US 47000YR
Add those together and you get more than the total, which is a bit confusing, but I think it's clear we need to decide how much we want to stop in Madrid...