Reason behind the inclusion and exclusion of current sources while using Ampere's law for the total magnetic field and total current The following definition of Ampere's law is from Concepts of Physics by Dr. H.C.Verma, from chapter 35, "Magnetic Field due to a Current", page 241:

The circulation $\oint\vec B.d\vec l$ of the resultant magnetic field along a closed, plane curve is equal to $\mu_0$ times the total current crossing the area bounded by the closed curve provided the electric field inside the loop remains constant. Thus,
$$\oint\vec B.d\vec l=\mu_0i\tag{35.10}$$

The author says that the magnetic field $\vec B$ on the left-hand side of the above equation is the resultant field due to all the currents either inside the area or outside it. However, the total current $i$ on the right-hand side of the above equation includes only the sum of current through the interior of the closed, plane curve with proper signs.
What is the reason behind the inclusion of magnetic field due to all currents, whether they cross the area or not, and exclusion of currents which do not pass through the area?
To make my question clear, let's consider the following diagram:

My questions are:

*

*Why do we consider the magnetic field $\vec B$ to be due to the currents $i_1,i_2,i_3,i_4$ and $i_5$? Why not just include $i_1,i_2$ and $i_3$?


*Why is the total current $i$ is given by $i_1+i_2-i_3$? Why not consider it to be $i_1+i_2-i_3+i_4-i_5$?
Is there any good reason behind these choices or is it only because Ampere's law "is a law"? I'm looking for an intuitive reason similar to that of Gauss law for electrical charges.

Please note: My question is different from Ampere's law and external currents even though they are related. The answers to the linked question didn't clarify my doubt.
 A: If you want to find $\vec{B}$ at a point then you must consider all possible sources that might lead to a magnetic field being present there. This is also the case for an electric field. The electric field at a point will depend on all possible charges present that could lead to a field at that point. 
But when we are using Ampere’s law we aren’t actually looking at $\vec{B}$ independently but at the quantity $$\int\vec{B}\cdot d\vec l$$
It turns out that if you integrate over a closed loop, the contribution by the currents that are outside the loop will turn out to be zero. So even if you consider the total field (arising from all currents) in the integral, the non-zero contribution comes only due to the current inside the loop.
$$\int\vec{B}_{tot}\cdot d\vec l= \int\left(\vec{B}_{ext}+\vec{B}_{int}\right)\cdot d\vec l $$
$$= \int\vec{B}_{ext}\cdot d\vec l+\int\vec{B}_{int}\cdot d\vec l $$
$$=0+ \int\vec{B}_{int}\cdot d\vec l$$
$$ = \int\vec{B}_{int}\cdot d\vec l $$
Where the notation means $\vec{B}_{ext}$ is due to currents outside the loop, $\vec{B}_{int}$ is due to currents inside the loop, and $\vec{B}_{tot}$ is the sum of the two. 
This again is analogous to the case of electric fields where in Gauss law, the contribution to the flux over a closed volume comes only from charges enclosed. And the contribution due to external charges is zero. 
A: If we have some steady current flowing in space (hypothetical model) with density $\mathbf J$ then the magnetic field at any point in space is $$\mathbf B = \frac{\mu_0}{4\pi} \int \frac {\mathbf J \times \mathcal {\hat r} }{\mathcal {r}^2} dV$$ and we know that the the curl of magnetic field created by all current densities is $$ \nabla \times \mathbf B = \mu_0 \mathbf J$$ 
Now, let's imagine a surface $\boldsymbol{\sigma}$ and let's denote it's boundary by $\mathbf l$
 . 
Take the surface integral with respect to $\sigma$ of the curl expression above, $$ \int_{\sigma} \left(\nabla \times \mathbf B \right)\cdot \boldsymbol{\sigma} = \int_{\sigma} \mu_0 \mathbf J \cdot \boldsymbol{\sigma}$$
The left hand of the above equation can be written by Stokes theorem (but notice that $\mathbf B$ is still by all volume current densities) $$ \oint \mathbf {B} \cdot d\mathbf l = \mu_0\int_{\sigma}  \mathbf J \cdot \boldsymbol{\sigma}$$ now notice 
$\int_{\sigma}  \mathbf J \cdot \boldsymbol{\sigma}$ is just the current flowing through the surface $\sigma$, therefore $$ \oint \mathbf B \cdot d\mathbf l = \mu_0 I$$.  
So, you see $\mathbf B$ in Ampere's law is due to all current densities but it's circulation around any closed loop depends only on the net current flowing through the surface defined by that loop. 
