$N$ is even (if not then all $d_i$ are odd, making $\sum_{i=1}^4 d_i^2$ even). Therefore $d_1=1$ and $d_2=2$, and at exactly one of $d_3$ and $d_4$ is even.

Suppose that $4 \mid n$. Then one of $d_3, d_4$ is $4$ and the other is an odd prime $p$. Since $N=21+p^2$ and $p \mid N$, we have $p \mid 21$. But $4 \nmid 21+3^2$ and $5 \mid 21+7^2$, ruling out both choices of $p$.

Thus $4 \nmid n$. $d_3$ is an odd prime $p$ and $d_4$ is even. Since $d_4/2$ is a smaller divisor, it could only be $d_3$. Therefore $N = 1+4+p^2+4p^2 = 5(1+p^2)$. $3$ cannot divide a number of this form, and clearly $5$ does. Therefore $d_3=5$ and $d_4=10$, uniquely determining $N=130$.


The equation $$N = 1 + d_1^2 + d_2^2 + d_3^2$$ implies $N$ even by reducing $\mod 2$. Suppose $2^2|N$ then there are three possible cases:

  • $N = 1 + 2^2 + 4^2 + 8^2$ - but this is impossible by arithmetic.
  • $N = 1 + 2^2 + 4^2 + p^2$ (with $p>3$) - but reducing $\mod p$ we find $0 \equiv 13 \pmod p$ so $p = 13$ but this too is impossible by arithmetic.
  • $N = 1 + 2^2 + 3^2 + 4^2$ - impossible by arithmetic.

So $2$ is the highest power of $2$ dividing $N$, thus we have the cases:

  • $N = 1 + 2^2 + p^2 + q^2$ (with $q < 2p$) but this is impossible by reducing $\mod 2$
  • $N = 1 + 2^2 + p^2 + (2p)^2$ so $N = 5(1+p^2)$ and $5|N$ so $p$ must be $3$ (impossible by arithmetic) or $5$.

This shows the only possible solution is $130$.