use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

const MOD: u64 = 1_000_000_007;

fn modpow(a: u64, b: u64) -> u64 {
    let mut a = a;
    let mut b = b;
    let mut res = 1;
    while b != 0 {
        if b & 1 != 0 {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        b /= 2;
    }
    res
}

fn is_prime(n: u32) -> bool {
    if n <= 1 {
        false
    } else if n == 2 || n == 3 || n == 5 {
        true
    } else if n % 2 == 0 || n % 3 == 0 || n % 5 == 0 {
        false
    } else {
        for i in 2..n {
            if i * i > n {
                break;
            }
            if n % i == 0 {
                return false;
            }
        }
        true
    }
}

fn is_prime_table(n: usize) -> Vec<bool> {
    let mut is_prime = vec![true; n + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..n+1 {
        unsafe {
            if *is_prime.get_unchecked(i) {
                let mut j = i * i;
                while j <= n {
                    *is_prime.get_unchecked_mut(j) = false;
                    j += i;
                }
            }
        }
    }
    is_prime
}

fn prime_table(n: usize) -> Vec<u64> {
    let is_prime = is_prime_table(n);
    is_prime.iter().enumerate()
        .filter(|&(_, &isp)| isp).map(|(i, _)| i as u64)
        .collect()
}


fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn s(x: i64) -> i64 {
    if x == 0 {
        0
    } else {
        x / x.abs()
    }
}

fn func(a: &Vec<i64>, sign: i64) -> u64 {
    let mut sign = sign;
    let mut ans = 0;
    let mut acc = 0;
    for &x in a.iter() {
        if s(acc + x) == sign {
            acc += x;
        } else {
            ans += (acc + x - sign).abs() as u64;
            acc = sign;
        }
        sign *= -1;
    }
    ans
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let n = sc.read();
        let a: Vec<i64> = sc.vec(n);
        let ans = func(&a, 1);
        let ans = min(ans, func(&a, -1));
        println!("{}", ans);
    }
}


Measured memory_bytes: 8572