Tabs vs Spaces

5

1 votes
Very-Easy
Problem

Pied Piper's CEO Richard Hendricks is all about conserving space and time. (That’s the whole point of compression.) Therefore, he prefers Tabs over Spaces. Recently, he got into a feud with his girlfriend Winnie. Winnie prefers Spaces over Tabs. Richard wants to prove his point, but he has to improve the Weissman Score of his compression algorithm. Your first task is to help Richard win this war of Tabs vs Spaces.

You will be given an array A of size N. Each element will represent the number of consecutive spaces used in Winnie's code. You have to tell the difference in the number of characters required if Winnie would have used Tabs instead of Spaces.


Constraints:

1 Tab = 4 Spaces

1 <= N <= 10^6

1 <= A[i] <= 10^6


Input:

First line will contain N
Next N lines will contain N numbers


Output:

A single line containing the answer


Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The array has 3 elements
4 Spaces = 1 Tab = 1 Character
2 Spaces = 2 Spaces = 2 Characters
6 Spaces = 1 Tab + 2 Spaces = 3 Characters
Hence the total characters Richard Used: 1 + 2 + 3 = 6
Whereas Winnie used a total of: 4 + 2 + 6 = 12 characters.
Hence, the difference: 12 - 6 = 6

Editor Image

?