Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=n
for i in range(n-1):
  c = g[i]
  for j in range(i+1,n):
    f=False
    for k in range(20):
      c[k]+=g[j][k]
      if c[k]>=2:
        f =True
        break
    if f:
      break
    else:
      ans+=1
print(ans)

Fixed submission:
n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=0
b =0
c =0
d= [0]*20
s=1
while(1):
  e =0
  if s ==1:
    for i in range(20):
      d[i]+=g[c][i]
      if d[i]>=2:
        e+=1
  else:
    for i in range(20):
      d[i]-=g[b-1][i]
      if d[i]>=2:
        e+=1
  if e==0 and c!=n-1:
    s=1
    c+=1
  elif e!=0:
    ans+=c-b
    s=0
    b+=1
  else:
    ans+=c-b+1
    s=0
    b+=1
    if b==n:
      break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=n
for i in range(n-1):
  b = a[i]
  c = g[i]
  for j in range(i+1,n):
    b+=a[j]
    d=0
    for k in range(20):
      c[k]+=g[j][k]
      d+=(2**k)*(c[k]%2)
    if b==d:
      ans+=1
print(ans)

Fixed submission:
n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=0
b =0
c =0
d= [0]*20
s=1
while(1):
  e =0
  if s ==1:
    for i in range(20):
      d[i]+=g[c][i]
      if d[i]>=2:
        e+=1
  else:
    for i in range(20):
      d[i]-=g[b-1][i]
      if d[i]>=2:
        e+=1
  if e==0 and c!=n-1:
    s=1
    c+=1
  elif e!=0:
    ans+=c-b
    s=0
    b+=1
  else:
    ans+=c-b+1
    s=0
    b+=1
    if b==n:
      break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=n
for i in range(n-1):
  b = a[i]
  c = g[i]
  for j in range(i+1,n):
    b+=a[j]
    d=0
    for k in range(20):
      c[k]+=g[j][k]
      d+=(2**k)*(c[k]%2)
    if b==d:
      ans+=1
print(ans)

Fixed submission:
n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=0
b =0
c =0
d= [0]*20
s=1
while(1):
  e =0
  if s ==1:
    for i in range(20):
      d[i]+=g[c][i]
      if d[i]>=2:
        e+=1
  else:
    for i in range(20):
      d[i]-=g[b-1][i]
      if d[i]>=2:
        e+=1
  if e==0 and c!=n-1:
    s=1
    c+=1
  elif e!=0:
    ans+=c-b
    s=0
    b+=1
  else:
    ans+=c-b+1
    s=0
    b+=1
    if b==n:
      break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
a = list(map(int, input().split()))
ans=n
for i in range(n-1):
  b = a[i]
  c = a[i]
  for j in range(i+1,n):
    b+=a[j]
    c^=a[j]
    if b==c:
      ans+=1
print(ans)
    

Fixed submission:
n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=0
b =0
c =0
d= [0]*20
s=1
while(1):
  e =0
  if s ==1:
    for i in range(20):
      d[i]+=g[c][i]
      if d[i]>=2:
        e+=1
  else:
    for i in range(20):
      d[i]-=g[b-1][i]
      if d[i]>=2:
        e+=1
  if e==0 and c!=n-1:
    s=1
    c+=1
  elif e!=0:
    ans+=c-b
    s=0
    b+=1
  else:
    ans+=c-b+1
    s=0
    b+=1
    if b==n:
      break
print(ans)