import sys int1 = lambda x: int(x) - 1 # input = lambda: sys.stdin.buffer.readline() input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) i1 = lambda: int1(input()) mi = lambda: map(int, input().split()) mi1 = lambda: map(int1, input().split()) li = lambda: list(mi()) li1 = lambda: list(mi1()) lli = lambda n: [li() for _ in range(n)] INF = float("inf") mod = int(1e9 + 7) # mod = 998244353 n = ii() a = li() A = 200 ans = 0 for k in range(A + 1): dp = [[0] * (k + 1) for m in range(3)] dp[0][k] = 1 for i in range(n): nxt = [[0] * (k + 1) for m in range(3)] for m in range(3): p = m + 1 if m + 1 <= 2 else 2 for j in range(k + 1): nxt[m][j] += dp[m][j] if a[i] - k <= 0 and 0 <= j + a[i] - k: nxt[p][j + a[i] - k] += dp[m][j] dp = nxt ans += dp[2][0] print(ans)