Minor changes:

P = monthly payment

A = amount borrowed (principal)

i = monthly interest

n = total number of months (amortization)

The formula to calculate the monthly payment P is:

P = Ai / (1 - k) where k = 1 / (1 + i)^n

The total interest that will be paid is:

Pn - A

In other words, sum of all payments - amount borrowed

Example:

P = ?

A = 200000

i = .01 (12% annual cpd monthly)

n = 240 (20 years)

P = 200000(.01) / [1 - 1 / (1.01)^240] = 2202.1722...

Total interest = 240(2202.1722..) - 200000 = 328521.3441...

Hope that helps...