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OBuBBBMMOMGMOOGMOBBBBBBMr  rii   iii   i     i        qBBo  iiiii
OONSIVkEZOOMOMOMGOOOGOOOOMOMGOGOOOGMOMGNSkqZZMONNOOMMMOMGMOMMMOOOMOMMMOMMBGOGOOMOOOMMBVkBMMMGMOMGZGBMBOEPGMBNuLILii      i   i     i        MBBo iiiii
JkMOOEGZOGMOOOMGOOMGOGMOOGMOOGMOOGOGMGZPXSPqENNIVFkXGZOMBBMMMMMOMMMMMMMMMMMGOGOOOGOMBGoBBMMOOOOGqOBOGENGBBBOkvi         i i   i             YBBB  iii 
 IBMOMOOGOOOOMOMGOGOOMOMOOOOOMOMGOOMOOENPNNGZqXNXPkXkNNNXqkGMMOBMMMMOMOMMMOMOMOMOOOMMPOBOMOOOMMMMMGOMBMNri                       i   i      vBBZ iiiii
iXBOMOOGGZGGOGOGGZOOMOOGMOMGMOOOOOMOOGGqEEOGGPNqNqNNZEZPXFSSNNMOBMMMBMOOMMMOMOMOMOMOOqBMMOMMBMMOOEkori                        i   i         iBBY iiii 
ZMOOGMGOZGZZZOZOGOZGGOOOOMGMOMGMGMGOOONNNOOONNNZNGEGEEqNPNPGGBMMMMGGMBMOOBMMOMOMMBMBGFMBMBBMGMOOGGqNkPNONFLLriiiiiii iiiii i i              iBBi iiiii
MOOOMOMOOEZNGZGOMOENGGMOMOOOMOMOMMMOOGENGOMNENZNZNGGENZNNNZNGGOGZXVoMMMGMMMMMOMMMMBBBBBBBBMGEkZOMOBOMOEPPXNXNNGqPUoviiiiiii i   i     i     iBB iiiiii
OOGOOMGOOOZOGOENNOOOGOGMOMOMOMOMOMOOGGEZGMGNEGEGEGGONZNEEGNqXZZOENFVNBGOMMMMMMOMMBBMBGJi irLrjGBGMMMMBEFJLiiiiiiiii      i i i i     i      iBE iiirrr
OGOOMOOOOGOOBZFuvkBBMMOGOGMGMOOOMOOOOZGGMOGZZZGGOGOEGZGNGZGXEEGGOOONPNMOOGMMMOMMBBj       rqGGqoqNZMGqMBBBBEYi  irrii iiiiiiiii   i   i     oBv irrvr 
GGGOGOGMOMBBGkoviJGBBBOOGGGOOOGOOMOOOGZOOOEGGGGGGOGOGGEENGGZXNNGZOOOGGGGGMOMMBBBBS         ZOYSMOIrviiFurBBv MjirivYriiiiiiiiiii ii         BB iivri  
OGOGOGOOMMMqYrLi iJXBBMMMGOOMGOOOOOGOZOGMGGEOGOOMGOGOGOZOGOZEXNNZZGGOZOGOOMOMMBBU     i i iPVJMMOEFjr iYirOJoNiiiiivLiiiiiiiiii   i        iBS iri  iL
GOOOGMMBBBUiiiriii iOBBBMMOOGOGMOMOOGOOMGGGGZOGOGGGOGOGOGGOONqPNNZNENZZGZOZMMMZYi      iiiivuEGGNPIoLiiruVPGui       i iiiii i i i i   i   OBiiri  ruN
OGOOMOGMBUiiiiiiii  LBBBBOMOOGOOMOMOMGMMOZOGOGOGGZOZOGGZOGMOZNNPNPZNZEZEGZGOBZjri     i i i irXGOGZXPkXuLii         i iiiiiiiii i     i   iMq r  iLFEj
OMMBMNvoPi iiiiiiriiiiXBMBMMOOOMOOGMGOGOGGGOGOGOZOOOGGZOGOGOGEqNqNqZNZNGEGEOOSLii i    i i     iJNqNPqIJvii  i iiiiiiiiiii i iii     i    BBi   ijFEU 
MMMMMjrriiiriiiirrLvi iJqMBMMOMOMGOOMGMOOGOGMGMGOGOGOGOGOGOOMGNqNPqqNNZNZNGMMoviiii              ivYuULiriiii   iiiiiiiii i i i   i i i  GBu  irukPv  
BGrvNqSr  iviiirviiri  iiYGBMMOMOOOOGMOOGOGOOOGOGOGOGGZOOOGOOMNNNNXNqNPNqEGMOIviii     i       i   iiviiiiiiiiiiiiiiiiiiiiii            UBO  irUSIi  v
BL  Ujii  ivJriirii i  ir LOBMMOMGOOMGMGOGOGOOOGOGOGOGOGOGMGOMOqGNNPqPNqNNOMOuriiii   i     i   iii iiiiiiiiiiiiiiiiiii i i   i i i    kBr  irUPL   UM
vi iPr ii  iJIiiiii  iiLviiPMBMMGOGMGMOOGOOOGOGOOOGOGOGOGOGOGMOONZXqPqXNPEOBZoii i           i   iiiiiiiiiiiiiiiiiiiiiii i iii   i   iBB  irLNPi  iEBB
rLIiov  iii ijvriiiiiiiivLvuMBMOOGOOOOMGOOMOOOOOOGOGOGOGMGOGMOMGGNEqqPNXqNMBELi i     i i i i     iiiiiiiiiiiiiiiiiiiii i iii i     vBN  roXGo   JMBBU
UFBJiLi  rrii iiiiiiiiiiiuuLNMOMOOGMOOOOGOOMGOGOOOGOGOGOOOGOOMMOMGNZNNPNqGMMVv       i   i   iii   iiiiiiiiiiiiiiiiiiiiiii i       GBi irNZOr  iIMOZv 
Siuv iLi iULi  iiiiiiiiiivjirSMGOGMOMGMOOOMOOGEGOGOGOGOGOGOOOOMNMMGNNqqNZEMEYi  i i     i     iirii iiiiiiiiiiiiiiiiiii i iii    rBZ  iJNONi  rNNXoi  
U  v  JBji iii iiiiiiiiiirr rMMOGGGMOMGOOOOMGGGOGOGOOMOOGOOOGMMqGBOZEGNENOOkiiii         i      rjriiiiiiiiiiiiiiiiiiiiiii i    MBr ivuGMS   oPXVvi  N
X  vF iGOi  iiiiiiiiiiii iiuBBMOOGOMMOOGMOMOOGMGOGOGOOOGOGOOMOOVBMBOEEZNNPPuiiiii     i   i     iLqUriiiiiiiiiiiiiiii iii     IMO  rvYNOv  ioSVjri  OB
Uu vBqi ii iiiiiii iiii  iBBMMOONEGBOMGOOOOMOOGOGOZGGOOOGOOMOBUoBBMBGZEZqIvLii i         i     irvjNNuiiiiiiiiiiii i i      vBBi irrrqX   rFJvri   BBF
rMSvBBri  iiiiiiiiiiii  iBBBMOZPNPLZBOOOMGMGOOOGOGGGOGOGOGMGMMkuBMMMBOGGNuLvi                  vuvriLSEYiiiiiiiii i       LBBu  rrivNY  ivuuLii  iBBO 
rNMGuiiriiiiiiiiiiiii  vMBMMGOEOBv OBMOMGOOOGOGOGOOOGOGOGOGOGMMLEBMMMBGEZkuoLi         iiiiiiiiiiiiiiivUYviiiiiiiii     vBBE  irrrUOi  iruLJri  iBMO  
UoZoi iiiiiiiiiiiiii  LBBOGOOGMBU SBMOMOMGOGOGOGOGOOOGOOMGOOOGBELBBMMMBNZGNFkui    iiiiiiiiiiiiiiiiii iiirriiiiii    ijMBBr iivrvkU  iiiJvrii  rBBO  i
ONLriiiiiiiiiiiiiii  vBBMMOOOMBq LBBOMOMOMOOOOGOGOOMGOGOOMOOOMOBuNBMMMMMGGGOOMMSvuOBOi iiiii iii iiiii i iiiiiiiii rFBBBBr XvLLuUi  iiirriii  jBBZ  rS
juviiiiiiiiiiiiiiii rBBMOOMGMMB iBBMMOOOOOMGOGMGOOOOOOOOOGMGOGMMGVBMMMMMBGGGMMBBBBMMMvi i iiiii iiiiiiiiii  iiiiiijZBBBBMiuNuLoi  iiiiiiiii  IBBG  LSZ
rrvrrrriiiiiiiiiii iMBMMOMOMMBi BBBMOMGMOOOOGOGOGOOOOOOOOOOOGMOMMPNBMBMBMMZGGGGMOPuqMNriiiiiiiiiiiiiiiiiiiii iiiirXMMBBBBIjSrv   iiiiiiiii  NBBE  ukXG
rivrrrrriiiiiiiii  OBBMOMOMMBN JBNPMMOMOMOOGMOOGOGOGMOOGOGMGOGMOMOIOBMMMMMMZOGGNEuiiEBorriiii   iiiiiiiii i   iiivqMMMBMBroi   iiiiiiiiii iNBBX  VPSEE
uLvvrrrrriiiiiiii iBBMOMMMMBBi BBXuBMOOMOOGOGMGOGOGOOMOOOMOOGOOOOBNFMBMMMMMMZGOMOOJvruriiiiii      i iiiiiiiiiiiruEBMBMBMNqv iiiiiiiiiii iMBBP  XNkGPN
uLJvvvrrrrriiiii  BBBOMOMOMMB VBGGNOBOOOOGMGOGOOMGOGOGOOMOMOOOMOOOBINBBMMMBMMZGGMBBMMNPoFuULvriivvvvLrvYVjvrriirvoOOMMBMMMOVviiiiiiiiii iBBBF iNNXPZOM
uJJjLLvvrrrriiii rBBMMOMOMMBv BMZOZjMBOMOMOOOOGMOOGMGOOOGMGMGOOOOOOMVOBMMMMBMMZG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OGOGOOOGOGOGOGOGOGOGGGMZi MXkMBGOZGEZGOMBBBOOENVSoj
qkOOMOMMBMMMBMBMBMBMMGMOMGMOMGMOMOMMMGMMMMBB  FBBOMMMMMMMMMOBBviBBMBGFMOOOMGXNijBMMOMOOGMOMOOOOGOOOGOGOOMOOOOGGGGGOGMGGGMGN iGUJBMOGOGOEBBBMZXXUuLuoqN
NZGMMMBBMBMBOMMMBBBGPEMMMMOMOMGMMMOMOGOMOMMBu  BBBMMOMOMMMMMMBBijBMBMPGMOMOMXGJiBBMMMMOMOOOMGMGOGOOOGMGOOOOMGOGOGOGMOGOMGGXivULjMBGOZOOBBGIVFkXNPqqqqq
r rvvjJvUvrVqSPvvvv  vIMOOMOMOOOMOMMMZOGOOBMB  iBMMOMOMGGOMOMMBNiIMOBZNOMOMMZEOivMMOMOOGMOOGOOOGOGOGOGOGMGOGOGGGOGOZGGEUuuv vvrvMMOGGGBMv iVNNZNNPNNGG
*/

long long a[100010];
long long sum[100010];
long long sum1[100010];
long long n;

long long main(){
	cin>>n;
	sum[0]=0;
	long long ans1=0,ans2=0;
	for (long long i=1;i<=n;i++) {
		cin>>a[n];
		sum[i]=sum[i-1]+a[n];
		if (i!=1) {
			if (sum[i]*sum[i-1]>=0){
				if (sum[i]>=0) {
					ans1+=sum[i]+1;
					sum[i]=-1;
				}
				else {
					ans1+=1-sum[i];
					sum[i]=1;
				}
			}
		}
	}
//	for (long long i=1;i<=n;i++) cout<<sum[i];
	sum1[0]=0;
	for (long long i=n;i>0;i--) {
		long long x=n-i+1;
		sum1[x]=sum1[x-1]+a[i];
		if (i!=n){
			if (sum1[x]*sum1[x-1]>=0){
				if (sum1[x]>=0){
					ans2+=sum1[x]+1;
					sum1[x]=-1;
				}
				else {
					ans2+=1-sum1[x];
					sum1[x]=1;
				}
			}
		}
	}
	cout<<min(ans1,ans2)<<endl;
//	cout<<ans1;
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'