How should this formula be interpreted? $$\large\mathbb P\left(\bigcup_{(i = 1)}^n A_i \right)= \sum_{k=1}^n (-1)^{k+1} {\sum_{1\leq i_1\lt\cdots\lt i_k\leq n} \mathbb P\left(A_{i_1} \cap \cdots \cap A_{i_k}\right)}\\$$
Can someone help me understand this formula?
 A: Let x be an element that belongs to k of the sets $A_i$, let that be sets $A_1,A_2...A_k$, you want to count it only once.
When you're adding single sets you count x k times, then when you subtract pairs you count x $k\choose 2$ times, and so on... until you count groups of k subsets $A_i$ when you count x once.
So number of times x was counted is $N_x=k-{k\choose 2}+{k\choose 3}-...\pm{k\choose k}=1-(1-1)^k=1$ so each element of the union is counted once.
A: 
I thought it was a general formula for a probability of a union, but
  when I chose n=3, and expanded the formula with that, it didn't seem
  to do that.

For $n=3$ the formula is
$P(A_1 \cup A_2\cup U_3)$
$=P(A_1)+P(A_2)+P(A_3)-P(A_1 \cap A_2)-P(A_1 \cap A_3)-P(A_2 \cap A_3)+P(A_1\cap A_2 \cap A_3)$
In the graph $A_1=A, A_2=B$ and $A_3=C$

1) 
$A+B+C$: $e,g$ and $n$ are counted once. $f,k,m$ are counted twice. $h$ is counted three times.
2) 
$-(A\cap B)$: $f$ and $h$ are subtracted.
$-(A\cap C)$:  $k$ and $h$ are subtracted
$-(B\cap C)$: $m$ and $h$ are subracted.
Summing up all sets (1&2): $e+g+n+ 2\cdot (f+k+m)+ 3\cdot h -f-h-k-h-m-h
=e+g+n+f+k+m$
3) 
Adding $A\cap B\cap C: h$
$A\cup B\cup C=e+g+n+f+k+m+h$
