Another way to do this is with the following code:
=IF(AND(A1=A2,A2=A3,A3=A4),A4+4,A4)
I got this idea from the following thread: Is there a way to find out the values of 4 cells are the same or different in MS Excel