/*
Sprendimo autorius: Linas Petrauskas
We know that:

m1 = (s1 + s2) / 2
m2 = (s2 + s3) / 2 

and so on... Thus we get:

s2 = 2*m1 - s1
s3 = 2*m2 - s2
...

Which means that by choosing s1 we choose the
whole sequence as other values can be simply
calculated. But which values of s1 are legal
(produce a non-decreasing sequence)? Let's see:

s1 <= s2 = 2*m1 - s1
2*s1 <= 2*m1
s1 <= m1

We get some upper bound for s1. That's indeed
natural: since m1 is the average of s1 and s2,
and s1 <= s2, s1 cannot be greater than m1! The
same applies to other values:

s2 <= m2
s3 <= m3
...

Let's express these inequallities in terms of
s1.

s2 = 2*m1 - s1 <= m2
We get some lower bound for s1:
s1 >= 2*m1 - m2

Further, since s3 <= m3:
s3 = 2*m2 - s2 = 2*m2 - (2*m1 - s1) = 2*m2 - 2*m1
+ s1 <= m3
We get:
s1 <= 2*m1 - 2*m2 + m3

Notice the pattern? Sure you'll notice after
seeing that
s1 >= 2*m1 - 2*m2 + 2*m3 - m4

We get all the lower and upper bounds for s1 this
way, choose the tightest ones and get the answer:
UPPERBOUND-LOWERBOUND+1.
*/

#include <cstdio>

    using namespace std;

#define INFINITY 2000000000

    int N;
    int MINBOUND = -INFINITY;
    int MAXBOUND = INFINITY;
    
int main()
{
    int m, X = 0;

    scanf("%d", &N);
    
    for (int i = 0; i < N; i++) {
        scanf("%d", &m);
        if (i % 2 == 0) { // new max bound
            X += m;
            if (MAXBOUND > X)
                MAXBOUND = X;
            X += m;
        } else { // new min bound
            X -= m;
            if (MINBOUND < X)
                MINBOUND = X;
            X -= m;
        }
    }
    
    int ANS = MAXBOUND - MINBOUND + 1;
    printf("%d\n", ANS > 0 ? ANS : 0);

    return 0;
}

