unittest
{
	assert( [ "4", "1 -3 1 0" ].parse.expand.solve == 4 );
	assert( [ "5", "3 -6 4 -5 7" ].parse.expand.solve == 0 );
	assert( [ "6", "-1 4 3 2 -5 4" ].parse.expand.solve == 8 );
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ps = 0L;
	auto pd = 0L;
	auto ms = 0L;
	auto md = 0L;
	
	foreach( i, a; as )
	{
		ps += a;
		ms += a;
		if( i % 2 == 0 )
		{
			if( ps <= 0 ) pd -= ps - 1, ps -= ps - 1;
			if( 0 <= ms ) md += ms + 1, ms -= ms + 1;
		}
		else
		{
			if( 0 <= ps ) pd += ps + 1, ps -= ps + 1;
			if( ms <= 0 ) md -= ms - 1, ms -= ms - 1;
		}
	}
	
	return min( pd, md );
}
