Hi, I need help to some simple algorithm

I have a variable that I receive each 5seconds a value like 10 ..20 ..34..56..75 on websocket
I need to store it in a array like value[n]

only with n and n-1 this means the actual value received and last value received
For example in above store only 34 and 56 and get its diference like 22 in a variable result

I was thinking about push and pop in arrays

Any help is welcome