for example

:

* means a coin

a triangle of coins like this:

*

* *

* * *

its number is 3

when i invert it it will be like that:

* * *

* *

*

for more explination:

http://www.spoj.pl/content/abhilash_i:invert

i want a formula to calculate the minimum transfers of coins to invert triangle