#include <stdio.h>

int main(void)
{
    int n, m;
    int i;
    int s;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        s = 0;
        for (i = 0; i < n / 4; i++){
            scanf("%d", &m);
            s += m;
        }
        printf("%d\n", s);
    }
    return (0);
}