#include int main(){ int P1,P2,N,R,M=0,c=0,i; scanf("%d%d",&P1,&P2); scanf("%d",&N); for(i = 0; i < N; i++){ scanf("%d",R); if(R == M){ c++; }else{ M = R; } } printf("%d",c*(P1+P2)); }