I'm trying to find out how potential function works. I'm trying to compute an amortised complexity of $n$ operations on dynamic array. To make it simple, assume, that we can't delete items and we can add item only to end of the array, so something like push. Let's assume that allocation is for free and if the array is full, we reallocate new array of double size and copy (cost 1 for each copy) all items into the new array.
It seems that $Ĉ$ - amortised price of one push is $2$. But how to create a potential function?
POTENTIAL_FUNCTION(Di) - $i$ is the number of items in the array
PUSH: $Ĉi$ = 1 + n + 1-n = 2 COPY: $Ĉi$ = i + ???
Please could you simple explain how to create potential function for this?