An empty linked list is given initially. Simulate the following operations:
push front : add element to the front of the linked list;
push back : add element to the back of the linked list;
pop front: remove the element from the front of the linked list;
pop back: remove the element from the back of the linked list.
Let L = (a_1, a_2, \ldots, a_n) be the resulting linked list. Find the sum of all odd elements.
Each line contains one of the operations described above. It is known that is a nonnegative integer, no more than . The final linked list (after simulation) contains no more than elements.
Print the sum of all elements at odd indices of the resulting linked list.
After simulation, the list will have the following form:
The sum of odd elements is 5 + 1 = 6.
Example 1