Problem:
Score : 300 points

Problem Statement

You are given an integer sequence of length N. The i-th term in the sequence is a_i.
In one operation, you can select a term and either increment or decrement it by one.

At least how many operations are necessary to satisfy the following conditions?

For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.

For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.

Constraints

2 ≤ n ≤ 10^5

|a_i| ≤ 10^9

Each a_i is an integer.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print the minimum necessary count of operations.

Sample Input 1

4
1 -3 1 0

Sample Output 1

4

For example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.

Sample Input 2

5
3 -6 4 -5 7

Sample Output 2

0

The given sequence already satisfies the conditions.

Sample Input 3

6
-1 4 3 2 -5 4

Sample Output 3

8

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
int A, B, C, D, E, F;

int main() {
    int n;
    cin >> n;
    vector<int> sum1(n);
    ll cnt1 = 0;
    vector<int> sum2(n);
    ll cnt2 = 0;
    vector<int> inp(n);
    REP(i, 0, n) {
        cin >> inp[i];
    }
    //最初を無理やり正に
    REP(i, 0, n) {
        if (i == 0) {
            sum1[i] = inp[i];

        } else {
            sum1[i] = sum1[i - 1] + inp[i];
        }
        if (sum1[i] <= 0 && i % 2 == 0) {
            int tmp = 1 - sum1[i];
            cnt1 += abs(tmp);
            sum1[i] += tmp;
        }
        if (sum1[i] >= 0 && i % 2 == 1) {
            int tmp = -1 - sum1[i];
            cnt1 += abs(tmp);
            sum1[i] += tmp;
        }
    }
    //最初を無理やり負にする
    REP(i, 0, n) {
        if (i == 0) {
            sum2[i] = inp[i];

        } else {
            sum2[i] = sum2[i - 1] + inp[i];
        }
        if (sum2[i] >= 0 && i % 2 == 0) {
            int tmp = -1 - sum2[i];
            cnt2 += abs(tmp);
            sum2[i] += tmp;
        }
        if (sum2[i] <= 0 && i % 2 == 1) {
            int tmp = 1 - sum2[i];
            cnt2 += abs(tmp);
            sum2[i] += tmp;
        }
    }
    cout << min(cnt1,cnt2) << endl;
    return 0;
}