AppFolio Interview Question

Given an array [1, 1, 2, 3, 4, 4, 4, 5], find sum such that two consecutive elements are same. For example, 1 + 4 + 4 = 9 as there are two 1s and three 4s