Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
l=0; r=0; res=0; sum_=0; ans=[]
for _ in range(10**6):
    if l == N and r == N:
        break
    note = r
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    f = note == r
    if f is False:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                ans.append((i,j))
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]
    l += 1
ans = len(list(set((ans))))
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
r = 0; sum_ = 0; res = 0; ans = 0
for l in range(N+1):
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    ans += length
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
l=0; r=0; res=0; sum_=0; ans=[]
for _ in range(10**6):
    if l == N and r == N:
        break
    note = r
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    f = note == r
    if f is False:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                ans.append((i,j))
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]
    l += 1
ans = len(list(set((ans))))
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
r = 0; sum_ = 0; res = 0; ans = 0
for l in range(N+1):
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    ans += length
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
l=0; r=0; res=0; sum_=0; ans=[]
for _ in range(10**6)
    if l == N and r == N:
        break
    note = r
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    f = note == r
    if f is False:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                ans.append((i,j))
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]
    l += 1
ans = len(list(set((ans))))
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
r = 0; sum_ = 0; res = 0; ans = 0
for l in range(N+1):
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    ans += length
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
l=0; r=0; res=0; sum_=0; ans=[]
while True:
    if l == N and r == N:
        break
    note = r
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    f = note == r
    if f is False:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                ans.append((i,j))
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]
    l += 1
ans = len(list(set((ans))))
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
r = 0; sum_ = 0; res = 0; ans = 0
for l in range(N+1):
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    ans += length
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def xor(hoge):
    res = hoge[0]
    for i in range(1,len(hoge)):
        res = res ^ hoge[i]
    return res

# O(n^2) 解法
def debug():
    N = int(input())
    A = list(map(int,input().split()))
    cnt = 0
    note = []
    for i in range(N):
        for j in range(i+1,N+1):
            part = A[i:j]
            res = xor(part)
            if res == sum(part):
                print(i,j)
                cnt += 1
                part_bin = [format(e,"b") for e in part]
                note.append(part_bin)
    print(cnt)

#---------メインコード----------#

def main():
    import sys
    sys.setrecursionlimit(10**9)
    N = int(input())
    A = list(map(int,input().split()))
    def syakutori(l=0,r=0,res=0,sum_=0,ans=[]):
        if l == N and r == N:
            return len(list(set((ans))))
        note = r
        for i in range(r,N):
            if res ^ A[i] == sum_ + A[i]:
                r += 1
                res += A[i]
                sum_ += A[i]
            else:
                break
        length = r - l
        f = note == r
        if f is False:
            for i in range(l,r+1):
                for j in range(i+1,r+1):
                    ans.append((i,j))
        #print(l,r)
        if length == 0:
            r += 1
        else:
            res -= A[l]
            sum_ -= A[l]
        return syakutori(l+1,r,res,sum_,ans)
    ans = syakutori()
    print(ans)

main()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
r = 0; sum_ = 0; res = 0; ans = 0
for l in range(N+1):
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    ans += length
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def xor(hoge):
    res = hoge[0]
    for i in range(1,len(hoge)):
        res = res ^ hoge[i]
    return res

# O(n^2) 解法
def debug():
    N = int(input())
    A = list(map(int,input().split()))
    cnt = 0
    note = []
    for i in range(N):
        for j in range(i+1,N+1):
            part = A[i:j]
            res = xor(part)
            if res == sum(part):
                print(i,j)
                cnt += 1
                part_bin = [format(e,"b") for e in part]
                note.append(part_bin)
    print(cnt)

#---------メインコード----------#

# 2次元リストのsetをとる関数を用意
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

def main():
    import sys
    sys.setrecursionlimit(10**9)
    N = int(input())
    A = list(map(int,input().split()))
    def syakutori(l=0,r=0,res=0,sum_=0,ans=[]):
        if l == N and r == N:
            return len(get_unique_list(ans))
        note = r
        for i in range(r,N):
            if res ^ A[i] == sum_ + A[i]:
                r += 1
                res += A[i]
                sum_ += A[i]
            else:
                break
        length = r - l
        f = note == r
        if f is False:
            for i in range(l,r+1):
                for j in range(i+1,r+1):
                    ans.append([i,j])
        #print(l,r)
        if length == 0:
            r += 1
        else:
            res -= A[l]
            sum_ -= A[l]
        return syakutori(l+1,r,res,sum_,ans)
    ans = syakutori()
    print(ans)

main()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
r = 0; sum_ = 0; res = 0; ans = 0
for l in range(N+1):
    for i in range(r,N):
        if res ^ A[i] == sum_ + A[i]:
            r += 1
            res += A[i]
            sum_ += A[i]
        else:
            break
    length = r - l
    ans += length
    if length == 0:
        r += 1
    else:
        res -= A[l]
        sum_ -= A[l]

print(ans)