a[9999],i;f(n){~scanf("%d",a+n)?f(n+1):0;n>3?a[n-2]+=a[n]:i|a[n]|n==1&&printf("%d%c",!i++?n-1:a[i-1],i?32:10);}main(){f(0);}