You have to pay the sum you see in the moment you take the loan.
The difference you are talking about is created because only workers in lumber/iron/stone get the leader or advisor bonus in production (10% or 5%).
man, read my post again, I was not talking about difference which occurs due to alliance leader's income bonus... I was talking about diffenece due to different amount of workers. Bank loan is based of your total income (don't remeber now exactly calculations) so less workers hired in mines mean less income as well as smaller loan and amount to be paid back (if in my variant of sum W to be paid back is true).
leader of alliance gets 10% production bonus
It was so and should be now in old versions, in v4a realms leader does not get 10 per cent bonus to his income, just 10 per cent of his income is generated into alliance vault