Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = list(list(map(int,input().split())) for i in range(m))

a.sort()
bc.sort(reverse=True,key=lambda x:x[1])
t = 0
for i in range(m):
    for j in range(bc[i][0]):
        if t != n:
            if a[t] < bc[i][1]:
                a[t] = bc[i][1]
                t+=1
            else:
                break

print(sum(a))


### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = list(list(map(int,input().split())) for i in range(m))

a.sort()
bc.sort(reverse=True,key=lambda x:x[1])
t = 0
for i in range(m):
    for j in range(bc[i][0]):
        if t != n:
            if a[t] < bc[i][1]:
                a[t] = bc[i][1]
                t+=1
            else:
                break
        else:
            break
    else:
        continue
    break

print(sum(a))
### BUGGY CODE ###

from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
s = [str(i) for i in s]

mi = 10**10
s.append("W")

for i in range(len(s)-1):
    fi = s[:i]
    la = s[i+1:]
    fi.sort()
    la.sort()
    fil = bisect.bisect(fi,"W")-bisect.bisect(fi,"E")
    mil = bisect.bisect(la,"E")
    mi = min(mi,fil+mil)
print(mi)

### FIXED CODE ###

from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

mi = 10**10

li = [0]*n
lin = [0]*n

for i in range(len(s)):
    if s[i] == "W":
        li[i] = 1
    if s[n-i-1] == "E":
        lin[i] = 1

li = np.asarray(list(accumulate(li)))
lin = np.asarray(list(accumulate(lin)))[::-1]
lis = li+lin

lis.sort()

print(lis[0]-1)
### BUGGY CODE ###

N, M = [int(nm) for nm in input().split()]
A = [-1]
for m in range(M):
  A.append(int(input()))
A.append(N+1)

import math
total_case = 1
for m in range(M+1):
  a1 = A[m]
  a2 = A[m+1]
  safe_stairs = a2 - a1 - 1
  if safe_stairs == 0:
    print(0)
    break
  howmany_jump1 = safe_stairs - 1
  mx_jump2 = howmany_jump1 // 2
  #２のジャンプは０回～（mx_jump2）回
  case = 0
  for j2 in range(mx_jump2 + 1):
    jump2 = j2
    jump1 = howmany_jump1 - (j2 * 2)
    c = math.factorial(jump1 + jump2) // (math.factorial(jump1) * math.factorial(jump2))
    case += c
  total_case *= case
else:
  ans = total_case % (10**9 + 7)
  print(ans)

### FIXED CODE ###

N, M = [int(nm) for nm in input().split()]
if M != 0:
  a = int(input())

C = [1, 0] # [-2段目, -1段目]
C += [0]*(N+10) # C = [-2段目, -1段目, 0段目, 1段目, 2段目, ...]
for n in range(0, N+1):
  if M == 0:
    C[n+2] = (C[n] + C[n+1]) % 1000000007
  else: # M > 0:
    if n != a:
      C[n+2] = (C[n] + C[n+1]) % 1000000007
    else: # n == a:
      C[n+2] = 0
      M -= 1
      if M > 0:
        a = int(input())

ans = C[N+2]  % 1000000007
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
G=[dict() for i in range(N)]
for i in range(M):
    u,v,s=map(int,input().split())
    G[u-1][v-1]=s
    G[v-1][u-1]=s
H=[[] for i in range(N)]
reached=[0 for i in range(N)]
q=[]
q.append(0)
H[0].append((0,1))
while(len(q)>0):
    r=q[-1]
    q.pop()
    reached[r]=1
    for p in G[r]:
        if reached[p]==0:
            q.append(p)
            for s in H[r]:
                H[p].append((G[r][p]-s[0],-s[1]))
flag=0
x=-1
for i in range(N):
    if len(H[i])>=2:
        X=set()
        Y=set()
        for r in H[i]:
            if r[1]==-1:
                X.add(r)
            else:
                Y.add(r)
        if len(X)>=2 or len(Y)>=2:
            print(0)
            exit()
        else:
            a=list(X)[0]
            b=list(Y)[0]
            z=a[0]-b[0]
            if z%2==1:
                print(0)
                exit()
            x=z//2
            if x<0:
                print(0)
                exit()
        flag=1
if flag==1 and x!=-1:
    print(1)
elif flag==1 and x==-1:
    print(0)
else:
    L=[]
    R=[]
    for i in range(N):
        if H[i][0][1]==-1:
            L.append(H[i][0][0])
        else:
            R.append(H[i][0][0])
    print(max([min(L)+min(R)-1,0]))


### FIXED CODE ###

#(x,y)...xt+yが書かれる
from collections import deque
N,M=map(int,input().split())
G=[{} for i in range(N)]
for i in range(M):
    u,v,s=map(int,input().split())
    u-=1;v-=1
    G[u][v]=s;G[v][u]=s
H=[(0,0) for i in range(N)]
t=None
q=deque([0])
H[0]=(1,0)
while(q):
    r=q.pop()
    for p in G[r]:
        s=G[r][p]
        tmp=(-H[r][0],s-H[r][1])
        if H[p]==(0,0):
            H[p]=tmp
            q.append(p)
        elif H[p]==tmp:
            pass
        else:
            if H[p][0]==tmp[0]:
                print(0)
                exit()
            else:
                a=H[p][1]
                b=tmp[1]
                if H[p][0]==-1:
                    a,b=b,a
                #t+a=-t+b
                #2t=b-a
                if (b-a)%2:
                    print(0)
                    exit()
                else:
                    t=(b-a)//2
'''
t+a>=0:t>=-a
-t+b>=0:t<=b
inf=max(a)
sup=min(b)
'''
if t==None:
    inf=0
    sup=10**18
    for i in range(N):
        if H[i][0]==1:
            inf=max(inf,-H[i][1])
        else:
            sup=min(sup,H[i][1])
    print(max(sup-inf-1,0))
else:
    ans=[None for i in range(N)]
    q=deque([0])
    ans[0]=t
    while(q):
        r=q.pop()
        for p in G[r]:
            if ans[p]==None:
                ans[p]=G[r][p]-ans[r]
                q.append(p)
    flag=1
    for i in range(N):
        for j in G[i]:
            if ans[i]+ans[j]!=G[i][j]:
                flag=0
                break
        if flag==0:
            break
    if flag and min(ans)>0:
        print(1)
    else:
        print(0)
### BUGGY CODE ###

N = int(input())
X = list(map(int,input().split()))
ans = 0
mod = 10**9+7
l=[1]*(N+1)
a=1
for i in range(2,N+1):
  a*=i
  a%=mod
  l[i]=a
x=X[-1]
for i in range(N-1):
  for j in range(i+1,N-1):
    a = j-i-1
    ans += (X[j]-X[i])*(l[a])%mod*l[N-1]%mod*pow(l[a+2],mod-2,mod)%mod
    
for k,y in enumerate(X[:N-1:]):
  a = N-k-2
  ans+=(x-y)*l[a]%mod*l[N-1]%mod*pow(l[a+1],mod-2,mod)%mod
print(ans%mod)

### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
import math
ans = 0
mod = 10**9+7
a = 0
ans = 0
for i in range(N-1):
  a += pow(i+1,mod-2,mod)
  ans += ((X[i+1]-X[i])%mod)*(a%mod)
  ans %= mod
  
ans *= math.factorial(N-1)%mod

print(ans%mod)
### BUGGY CODE ###

n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(1,len(a) + 1):
  s.append(s[idx-1] + a[idx-1])

cnt = 0
for l in range(1, n+1):
  for r in range(l, n+1):
    if (s[r] - s[l-1]) % m == 0:
      cnt += 1
print(cnt)


### FIXED CODE ###

n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(len(a)):
  s.append((s[idx] + a[idx]) % m)

c = {0:1}
ans = 0
for l in range(1, n+1):
  ans += c.get(s[l],0)
  c[s[l]] = c.get(s[l],0) + 1
print(ans)
### BUGGY CODE ###

import numpy as np
threshold = 10**18
n = input()
list_ = list(map(int, input().split()))

ans = 1
for i in list_:
  ans *= i
if ans > threshold:
  ans = -1

print(ans)

### FIXED CODE ###

import numpy as np
threshold = 10**18
n = input()
list_ = list(map(int, input().split()))

ans = 1
if 0 in list_:
  print(0)
else:
  for i in list_:
    ans *= i
    if ans > threshold:
      ans = -1
      break
  print(ans)
### BUGGY CODE ###

import numpy as np 

N,K,Q = map(int,input().split())

member = np.array([K]*N)

for _ in range(Q):
    x = int(input())
    member[x-1] += 1
    member -= 1

for i in range(N):
    if member[i] > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

import numpy as np 

N,K,Q = map(int,input().split())

member = np.array([K-Q]*N)

for _ in range(Q):
    x = int(input())
    member[x-1] += 1

for i in range(N):
    if member[i] > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

dif_max = 1-10**9
max = 1
min = 10**9
n_max = 0
n_max = int(raw_input())

price = [0]*n_max
for i in range(0, n_max):
    price[i] = int(raw_input())
for i in range(0, n_max-1):
    for j in range(0, n_max):
        if j <= i:
            if min >= price[j]:
                min = price[j]
        else:
            if max <= price[j]:
                max = price[j]
    if dif_max <= max - min:
        dif_max = max - min
    max = 1
    min = 10**9
print dif_max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline


def bfs(table, i, j):
    dq = deque()
    seen = set()
    if table[i][j] == "#":
        return -1
    h = len(table)
    w = len(table[0])
    ans = 0
    dq.append((i, j, 0))  # x,y,distance
    while dq:
        x, y, dis = dq.popleft()
        ans = max(ans, dis)
        seen.add((x, y))
        if x > 0 and (x - 1, y) not in seen and table[x - 1][y] != "#":
            dq.append((x - 1, y, dis + 1))
        if x < h - 1 and (x + 1, y) not in seen and table[x + 1][y] != "#":
            dq.append((x + 1, y, dis + 1))
        if y > 0 and (x, y - 1) not in seen and table[x][y - 1] != "#":
            dq.append((x, y - 1, dis + 1))
        if y < w - 1 and (x, y + 1) not in seen and table[x][y + 1] != "#":
            dq.append((x, y + 1, dis + 1))
    return ans


def main():
    h, w = [int(i) for i in input().strip().split()]
    grid = [list(input().strip()) for _ in range(h)]
    ans = -1
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                max_path = bfs(grid, i, j)
                ans = max(ans, max_path)

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque
 
def main():
    H,W=map(int,input().split())
    S=[]
    for i in range(H):
        s=input()
        S.append(s)
 
    G=[]
    for i in range(H):
        for j in range(W):
            tmp=[]
            if S[i][j]=="#":
                G.append(tmp)
                continue
            if i-1>=0:
                if S[i-1][j]==".":
                    tmp.append((i-1)*W+j)
            if i+1<=H-1:
                if S[i+1][j]==".":
                    tmp.append((i+1)*W+j)
            if j-1>=0:
                if S[i][j-1]==".":
                    tmp.append(i*W+j-1)
            if j+1<=W-1:
                if S[i][j+1]==".":
                    tmp.append(i*W+j+1)
            G.append(tmp)
 
    res=0
 
    for start in range(H*W):
        dist = 0
        v = [-1 for _ in range(H * W)]
        que=deque([])
        que.append(start)
        v[start]=dist
        while len(que)>0:
            next_index=que.popleft()
            next=G[next_index]
            for i in next:
                if v[i]==-1:
                    que.append(i)
                    v[i]=v[next_index]+1
 
        if max(v)>=res:
            res=max(v)
 
    print(res)
 
 
if __name__=="__main__":
    main()
### BUGGY CODE ###

from collections import Counter
s = input()[::-1]
T = [0]*(len(s)+1)
digit = 1

for i in range(1,len(s)+1):
    T[i] = (T[i-1]+digit*int(s[i-1])) % 2019
    digit = digit * 10

S = Counter(T)
ans=0
for i in S.values():
    ans+=(i*(i-1))//2

print(ans)

### FIXED CODE ###

from collections import Counter
s = input()[::-1]
T = [0]*(len(s)+1)
digit = 1

for i in range(1,len(s)+1):
    T[i] = (T[i-1]+digit*int(s[i-1]))
    T[i] = T[i] % 2019
    digit = digit * 10
    digit = digit % 2019

S = Counter(T)
ans = 0
for i in S.values():
    ans+=(i*(i-1))//2

print(ans)
### BUGGY CODE ###

n=int(input())
alist=list(map(int,input().split()))

ans=1
for i in range(n):
    ans*=alist[i]

if ans>pow(10,18):
    ans=-1

print(ans)

### FIXED CODE ###

n=int(input())
alist=list(map(int,input().split()))
import math
mini=min(alist)
if mini==0:
    ans=0
else:
    ans=1
    for i in range(n):
        ans*=alist[i]
        if ans>pow(10,18):
            ans=-1
            break


print(ans)
### BUGGY CODE ###

n,q = map(int,input().split())
#s=list(input())	
s = input()
index = -1
indexes = []
while True:
    index = s.find("AC", index + 1)
    if index == -1:
        break
    indexes.append(index)

for i in range(q):
    l,r = map(int,input().split())
    ans1 = -1
    ans2 = len(indexes) - 1
    for j in range(len(indexes)):
        if(l -1 <= indexes[j] and ans1 == -1):
            ans1 = j
        if (r < indexes[j]+2):
            ans2 = j -1
            break
    if (ans1 == -1):
        ans2 = -2
    print(ans2-ans1 + 1)



### FIXED CODE ###

n,q = map(int,input().split())
#s=list(input())	
s = input()
index = -1
indexes = []
while True:
    index = s.find("AC", index + 1)
    if index == -1:
        break
    indexes.append(index)
dp = []

for i in range (n):
    dp.append(len(indexes))
    if len(indexes)> 0 and indexes[0] == i:
        indexes.pop(0)
for i in range(q):
    l,r = map(int,input().split())
    print(dp[l-1] - dp[r-1])
### BUGGY CODE ###

N,M = map(int,input().split())
div = 1
for i in range(2,M//N+1):
    if M%i==0:
        div = i
print(div)


### FIXED CODE ###

N,M = map(int,input().split())
div = 1
for i in range(2,M//N+1)[::-1]:
    if M%i==0:
        div = i
        break
print(div)
### BUGGY CODE ###

S=input()
Q=int(input())
que=[]
for i in range(Q):
    q=input().split()
    que.append(q)
#print(que)
tmp=0
for i in range(Q):
    if que[i][0]=='1':
        tmp=1-tmp
    if que[i][0]=='2':
        if que[i][1]=='1':
            if tmp==0:
                S=que[i][2]+S
            else:
                S=S+que[i][2]
        else:
            if tmp==0:
                S=S+que[i][2]
            else:
                S=que[i][2]+S
#print(tmp)
ans=""
if tmp==1:
    for i in range(len(S)):
        ans=S[i]+ans
    print(ans)
    exit()

print(S)

### FIXED CODE ###

from collections import deque
S=deque(input())
ans=""
Q=int(input())
tmp=0
r=[]
l=[]

for i in range(Q):
    que=input().split()
    if que[0]=='1':
        tmp=1-tmp
    if que[0]=='2':
        if que[1]=='1':
            if tmp==0:
                #S=que[2]+S
                #l.append(que[2])
                #ans=ans+que[2]
                S.appendleft(que[2])
            else:
                #S=S+que[2]
                #r.append(que[2])
                #ans=que[2]+ans
                S.append(que[2])
        else:
            if tmp==0:
                #S=S+que[2]
                #r.append(que[2])
                #ans=que[2]+ans
                S.append(que[2])
            else:
                #S=que[2]+S
                #l.append(que[2])
                #ans=ans+que[2]
                S.appendleft(que[2])
#print(que)
"""
for i in range(Q):
    if que[i][0]=='1':
        tmp=1-tmp
    if que[i][0]=='2':
        if que[i][1]=='1':
            if tmp==0:
                S=que[i][2]+S
            else:
                S=S+que[i][2]
        else:
            if tmp==0:
                S=S+que[i][2]
            else:
                S=que[i][2]+S
"""
#print(tmp)
"""
for i in range(len(r)):
    S=S+r[i]
    ans=r[i]+ans
for i in range(len(l)):
    S=l[i]+S
    ans=ans+l[i]
"""
if tmp==1:
    print("".join(reversed(S)))
    exit()

print("".join(S))
### BUGGY CODE ###

R,G,B,N=map(int,input().split())
ans=0
for r in range(3000+1):
  for g in range(3000+1):
    temp=r*R+g*G
    if N>=temp and (N-temp)%B==0:
      ans+=1
print(ans)


### FIXED CODE ###

R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R+1):
  for j in range((N-i*R)//G+1):
    k=N-i*R-j*G
    if k%B==0 and k>=0:
      ans+=1
print(ans)
### BUGGY CODE ###

s = input()
q = int(input())

for i in range(q):
    query = input().split()
    if query[0] == '1':
        s = s[::-1]
        continue
    if query[1] == '1':
        s = query[2] + s
        continue
    s = s + query[2]
print(s)


### FIXED CODE ###

s = input()
q = int(input())

conv = 0
pre = []
pos = []
for i in range(q):
    query = input().split()
    if query[0] == '1':
        conv += 1
        continue
    if (int(query[1])+conv) %2 == 1:
        pre.append(query[2])
        continue
    pos.append(query[2])
if conv % 2 == 0:
    pre = ''.join(pre[::-1])
    pos = ''.join(pos[::1])
    s = pre + s + pos
else:
    pre = ''.join(pre[::1])
    pos = ''.join(pos[::-1])
    s = s[::-1]
    s = pos + s + pre
print(s)
### BUGGY CODE ###

num_limit = int(input())
s_limit = int(num_limit**0.5)
for i in range(1,num_limit+1):
    xyz_count = 0
    s_limit = int(i ** 0.5)
    for j in range(1,s_limit+1):
        if i <= j**2:
            break
        for k in range(1,j+1):
            if i <= j**2 + k**2 + j*k:
                break
            for l in range(1,k+1):
                if i < j**2 + k**2 + l**2 + j*k + k*l + l*j:
                    break
                elif i == j**2 + k**2 + l**2 + j*k + k*l + l*j:
                    if j > k:
                        if k > l:
                            xyz_count += 6
                        else:
                            xyz_count += 3
                    elif k > l:
                        xyz_count += 3
                    else:
                        xyz_count += 1
    print(xyz_count)

### FIXED CODE ###

num_limit = int(input())
num_list = [0] * num_limit
j_limit = int(num_limit ** 0.5)
for j in range(1,j_limit+1):
    for k in range(1,j + 1):
        for l in range(1,k+1):
            if num_limit >= j**2 + k**2 + l**2 + j*k + k*l + l*j:
                if j > k:
                    if k > l:
                        num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 6
                    else:
                        num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 3
                elif k > l:
                    num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 3
                else:
                    num_list[j**2 + k**2 + l**2 + j*k + k*l + l*j-1] += 1
for i in num_list:
    print(i)
### BUGGY CODE ###

s = input()
ct = 0
for i in range(len(s)):
    for j in range(i+4,len(s)+1):
        if int(s[i:j])%2019 == 0:
            ct += 1
print(ct)


### FIXED CODE ###

S = input()
m = 2019
dp = [0]*m
dp[0] = 1

acc, d = 0,1

for s in S[::-1]:
    acc = (acc + d*int(s)) % m
    dp[acc] += 1
    d = (d*10) % m

print(str(sum([n*(n-1)//2 for n in dp])))
### BUGGY CODE ###

n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

### FIXED CODE ###

n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])
### BUGGY CODE ###

def main():
    import sys
    import time
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    B = [int(x) for x in input().strip().split()]
    AB = [a - b for a, b in zip(A, B)]
    if A == B:
        print('Yes')
        exit()
    elif sum(AB) > 0:
        print('No')
        exit()
    ai = 0
    bi = 0
    while ai < N and bi < N:
        if ai != N-1 and A[ai] >= B[ai]:
            ai = min(N-1, ai+1)
            continue
        if (A[bi] - B[bi]) % 2 == 1:
            A[ai] += 2
            B[bi] += 1
            continue
        if bi != N-1 and A[bi] <= B[bi]:
            bi = min(N-1, bi+1)
            continue
        cnt = min(int((B[ai]-A[ai])/2 + .5), max(1, A[bi]-B[bi]))
        A[ai] += cnt * 2
        B[bi] += cnt
        if ai == N-1 and bi == N-1:
            if A[ai] - B[bi] == 1:
                A[ai] += 2
                B[bi] += 1
            break
    
    if A == B:
        print('Yes')
    else:
        print('No')




if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    import time
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    B = [int(x) for x in input().strip().split()]
    cnt = 0
    for a, b in zip(A, B):
        a_b = a - b
        if a_b > 0:
            cnt += a_b
        elif a_b < 0:
            cnt -= -a_b // 2
    
    if cnt <= 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
### BUGGY CODE ###


n = int(input())
ans_L = []
d_L = []

tmp = n
for val in range(1,int(n/2)+1):
    if n % val ==0:
        x = val
        y = int(n/val)
        tmp = min(tmp,int(x+y-2))
print(tmp)

### FIXED CODE ###

import math


n = int(input())
ans_L = []
d = []
for val in range(int(math.sqrt(n)+1),0,-1):
    if n % val ==0:
        x = val
        y = int(n/val)
        #st = str(x) + "*" +str(y)
        #d.append(st) 
        #ans_L.append(int(x+y-2))
        print(int(x+y-2))
        exit()
#print(d)
#print(ans_L)
#print(min(ans_L))
### BUGGY CODE ###

def rren(): return list(map(int, input().split()))
n, m = rren()
x = rren()
y = rren()
ans = 0
for now_x in range(n-1):
    for now_y in range(m-1):
        S = (x[now_x+1]-x[now_x])*(y[now_y+1]-y[now_y])
        count = (now_x+1)*(n-now_x-1)*(now_y+1)*(m-now_y-1)
        ans += S*count

print(ans%1000000007)

### FIXED CODE ###

def rren(): return list(map(int, input().split()))
n, m = rren()
x = rren()
y = rren()
ans = 0
x_sum = 0
y_sum = 0
for now_x in range(n):
    x_sum += x[now_x] * (now_x - (n-1 - now_x))
for now_y in range(m):
    y_sum += y[now_y] * (now_y - (m-1 - now_y))

print(x_sum * y_sum % 1000000007)
### BUGGY CODE ###

n = int(input())
li = list(map(int, input().split()))

ans = 0
for i in range(n):
  j = 0
  sum = 0
  xorsum = 0
  while i + j < n:
    sum = sum + li[i+j]
    xorsum = xorsum ^ li[i+j]
    if sum == xorsum:
      ans = ans + 1
    else:
      break
    j = j + 1

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = 0
w_xor,w_sum = A[0],A[0]
l,r = 0,0

while l < N and r < N:
  #print(l,r,w_xor, w_sum)

  if w_xor == w_sum:
    if r < N-1:
    #print(l,r)
      r += 1
      w_xor = w_xor ^ A[r]
      w_sum = w_sum + A[r]
      continue
    else:
      ans += 1+r-l
  else:
    # l,r-1、までがマッチしてたということなので1小さい
    ans += r-l
  w_xor = w_xor ^ A[l] 
  w_sum = w_sum - A[l]
  l += 1
  
print(ans)