4. (8 points) There are four people, A, B, C, and D. B owes A 1 yuan, C owes B 2 yuan, D owes C 3 yuan, and A owes D 4 yuan. To settle all debts among them, A needs to pay $\qquad$ yuan.

保留源文本的换行和格式，翻译结果如下：

4. (8 points) There are four people, A, B, C, and D. B owes A 1 yuan, C owes B 2 yuan, D owes C 3 yuan, and A owes D 4 yuan. To settle all debts among them, A needs to pay $\qquad$ yuan.
【Answer】Solution: According to the analysis, starting from A, B owes A 1 yuan, so A should receive 1 yuan, A owes D 4 yuan, so A should pay back 4 yuan;

When settling, A still needs to pay $4-1=3$ yuan, and then A's account is settled;
Now let's look at D's account, after D receives 4 yuan from A, D pays back 3 yuan to C, and then D's account is settled;
Now let's look at C's account, after C receives 3 yuan from D, C pays back 2 yuan to B, and then C's account is settled;
Now let's look at B's account, after B receives 2 yuan from C, B pays back 1 yuan to A, and then B's account is settled;
In summary, A only needs to first pay 4 yuan to D, and then receive 1 yuan from B, so A only needs to pay a total of 3 yuan.
Therefore, the answer is: 3.