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

def get_ij(ij, S, rem_i):
    length = len(rem_i)
    for i in range(length):
        for j in range(i+1, length):
            ij.append([rem_i[i], rem_i[j]])
    
    return 0

S = input()
length = len(S)
ruiseki_sum = [0]*length
ruiseki_sum[0] = int(S[0])
for i in range(length):
    if i != 0:
        ruiseki_sum[i] = ruiseki_sum[i-1] + int(S[i])

ruiseki_rem = [0]*length
for i in range(length):
    ruiseki_rem[i] = ruiseki_sum[i] % 3

rem_0_i = list()
rem_1_i = list()
rem_2_i = list()

for i in range(length):
    if ruiseki_rem[i] == 0:
        rem_0_i.append(i)
    elif ruiseki_rem[i] == 1:
        rem_1_i.append(i)
    else:
        rem_2_i.append(i)
    
ij = list()
get_ij(ij, S, rem_0_i)
get_ij(ij, S, rem_1_i)
get_ij(ij, S, rem_2_i)

# print(rem_0_i)
# print(rem_1_i)
# print(rem_2_i)
# print(ij)

ans = 0
for ind in range(len(ij)):
    i = ij[ind][0] + 1
    j = ij[ind][1] + 1
    if int(S[i:j]) % 2019 == 0:
        # print(S[i:j], i, j)
        ans += 1

for i in range(1, length):
    if int(S[:i]) % 2019 == 0:
        # print(S[:i], i, j)
        ans += 1
print(ans)

### FIXED CODE ###

S = list(reversed(input()))

length = len(S)

a = [0]*length
for i in range(length):
    pickup = int(S[i])
    a[i] = pickup*pow(10, i, 2019)

b = [0]*(length+1)
for i in range(1, length+1):
    b[i] = (b[i-1] + a[i-1]) % 2019
cnt, ans = [0] * 2019, 0
for x in b:
    ans += cnt[x]
    cnt[x] += 1

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

from itertools import count

N = int(input())
S = input()

abc = 'abcdefghijklmnopqrstuvwxyz'

T = ['']

flag = True
for i in count():
    T2 = T[:]
    T = []
    for t in T2:
        for c in abc:
            if S.count(t + c) > 1:
                T.append(t + c)
                flag = False
    if flag:
        print(i)
        break
    flag = True



### FIXED CODE ###

N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if S[i] == S[j]:
            tmp = 1
            if i > 0:
                tmp += dp[i - 1][j - 1]
            if j - i < tmp:
                continue
            dp[i][j] = tmp
        ans = max(ans, dp[i][j])
print(ans)
### BUGGY CODE ###

from heapq import nlargest
N = int(input())
A = list(map(int, input().split()))
f = [[a] for a in A]
for i in range(N):
    for j in range(1<<N):
        if j & 1<<i:
            f[j] = nlargest(2, f[j]+f[j^(1<<i)])
Ans = [sum(f[1])]
for v in f[2:]:
    Ans.append(max(Ans[-1], sum(v)))
print("\n".join(map(str, Ans)))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
f = [[a] for a in A]
for i in range(N):
    for j in range(1<<N):
        if j & 1<<i:
            f[j] = sorted(f[j]+f[j^1<<i], reverse=True)[:2]
Ans = [sum(f[1])]
for a, b in f[2:]:
    Ans.append(max(Ans[-1], a+b))
print("\n".join(map(str, Ans)))
### BUGGY CODE ###

def gcd(a, b):
	if a > b:
		a, b = b, a
	if a % b == 0:
		return b
	while a % b != 0:
		c = a% b
		a, b = b, c
	else:
		return c

def lcmCalc(x, y):
	return int((x * y) / gcd(x, y))

n, m = map(int, input().split())
s = input()
t = input()

lcm = lcmCalc(n, m)

str1 = ""
for i in range(lcm):
	str1 += "-"

for i in range(n):
	index = int(i * lcm / n + 1)
	str1 = str1[:index] + s[i] + str1[index+1:]

flg = 0
for i in range(m):
	index = int(i * lcm / m + 1)
	if str1[index:index+1] != "-" and str1[index:index+1] != t[i]:
		print("-1")
		flg = 1
		break

if flg == 0:
	print(lcm)

### FIXED CODE ###

def gcd(a, b):
	if a > b:
		a, b = b, a
	if a % b == 0:
		return b
	while a % b != 0:
		c = a% b
		a = b
		b = c
	else:
		return c

def lcmCalc(x, y):
	return (x * y) // gcd(x, y)

n, m = map(int, input().split())
s = input()
t = input()

lcm = lcmCalc(n, m)

# str1 = ""
# for i in range(lcm):
# 	str1 += "-"

flg = 0
for i in range(n):
	index = i * lcm // n + 1
	if (index - 1) % (lcm // m) == 0:
		j = (index - 1) // (lcm // m)
		if s[i] != t[j]:
			print("-1")
			flg = 1
			break
if flg == 0:
	print(lcm)


# 	str1 = str1[:index] + s[i] + str1[index+1:]

# flg = 0
# for i in range(m):
# 	index = i * lcm // m + 1
# 	if str1[index:index+1] != "-" and str1[index:index+1] != t[i]:
# 		print("-1")
# 		flg = 1
# 		break

# if flg == 0:
# 	print(lcm)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = sorted([a[i] - i - 1 for i in range(n)])
c = [i + (0 - b[0]) for i in b]

d = []
while c[-1] != -1:
    d.append(sum([abs(i) for i in c]))
    for i in range(len(c)):
        c[i] -= 1

print(min(d))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = sorted([a[i] - i - 1 for i in range(n)])
c = [i + (0 - b[0]) for i in b]

d = []
if n == 1:
    print(0)
else:
    if n % 2 == 1:
        d.append(0 - c[n//2])
    else:
        d.append(0 - c[n//2])
        d.append(0 - c[n//2 - 1])
        d.append(1 - c[n//2])
        d.append(-1 - c[n//2 - 1])

    ans = []
    for j in d:
        e = [i + j for i in c]
        ans.append(sum([abs(i) for i in e]))

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

n = int(input())

tt = list(map(int, input().split()))
v = list(map(int, input().split()))

time = sum(tt);

border = [0] *(n+1)
start_v = [0] *(n+1)
end_v = [0] *(n+1)

temp = 0
for i in range(n):
	temp += tt[i]
	border[i+1] = temp
	start_v[i] = v[i]
	end_v[i+1] = v[i]

t = 0
idx = 0
ans = 0
vlast = 0

# print (border)
while t < time :
	t += 0.5

	#直接制約
	v0 = v[idx]
	if t == border[idx+1]:
		idx += 1
#		v0 = min(v0, v[idx])

	for j in range(len(border)):
		
		if border[j] <= t:
			#前の時刻からの制約
			temp = end_v[j] + (t - border[j])
			if v0 > temp:
				v0 = temp
		if border[j] >= t:
			#後ろの時刻からの制約
			temp = start_v[j] + (border[j] - t)
			if v0 > temp:
				v0 = temp

#	print(v0)
	ans += 0.5 * (vlast + v0) / 2
	vlast = v0


print (ans)



### FIXED CODE ###

n = int(input())

tt = list(map(int, input().split()))
v = list(map(int, input().split()))

time = sum(tt);
INF = 999999
border = [0] *(n+1)
start_v = [0] *(n+1)
end_v = [0] *(n+1)

temp = 0
for i in range(n):
	temp += tt[i]
	border[i+1] = temp
	start_v[i] = v[i]
	end_v[i+1] = v[i]

t = 0
idx = 0
ans = 0
vlast = 0
v0 = 0
new_interval = False
limitation_front =0 # 最初の計算に必要

# print (border)
while t < time :
	t += 0.5
	new_interval = False

	#直接制約
	v0 = v[idx]
	if t == border[idx+1]:
		idx += 1
		new_interval = True
#		v0 = min(v0, v[idx])

	if(not new_interval):
		limitation_front += 0.5
		if v0 > limitation_front:
			v0 = limitation_front
	
	if new_interval: 
		limitation_front = INF
		for j in range(n+1):
			if border[j] <= t:
				#前の時刻からの制約
				temp = end_v[j] + (t - border[j])
				if v0 > temp:
					v0 = temp
				if limitation_front > temp:
					limitation_front = temp
			else:
				break
			#print (limitation_front)


	for j in range(n+1):
		if border[j] >= t:
			#後ろの時刻からの制約
			temp = start_v[j] + (border[j] - t)
			if v0 > temp:
				v0 = temp

	#print(v0)

#	ans += 0.5 * (vlast + v0) / 2
	ans += (vlast + v0)
	vlast = v0

ans /= 4.0
print (ans)
### BUGGY CODE ###

S = input()
Q = int(input())
parity = 0

for i in range(Q):
    query = input().split()
    if int(query[0]) == 1:
        parity += 1
    else:
        if int(query[1]) == 1 + (parity % 2):
            S = query[2] + S
        else:
            S = S + query[2]

if parity % 2 == 1:
    S = S[::-1]
print(S)

### FIXED CODE ###

from collections import deque
S = deque(list(input()))
Q = int(input())
parity = 0

for i in range(Q):
    query = input().split()
    if len(query) == 1:
        parity += 1
    else:
        if int(query[1]) == 1 + (parity % 2):
            S.appendleft(query[2])
        else:
            S.append(query[2])
S = ''.join([c for c in S])
if parity % 2 == 1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
mod = 1000000007
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
ans = 0
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    dp[i] %= mod
    if i in a:
        continue
    if i + 1 <= n:
        dp[i+1] += dp[i]
    if i + 2 <= n:
        dp[i+2] += dp[i]
print(dp[n] % mod)

### FIXED CODE ###

MOD = 10 ** 9 + 7
n, m = map(int, input().split())
broken = [False] * (n + 1)
for i in range(m):
    a = int(input())
    broken[a] = True
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    dp[i] %= MOD
    if broken[i]:
        dp[i] = 0
    if i + 1 <= n:
        dp[i+1] += dp[i]
    if i + 2 <= n:
        dp[i+2] += dp[i]
print(dp[n] % MOD)
### BUGGY CODE ###

mod = 998244353
  
def comb(n, r):
    if 2*r > n: return comb(n, n-r)
    return fac[n] * inv[r] * inv[n-r] % mod

n, a, b, k = map(int, input().split())

fac = [1] * (n+2)
inv = [1] * (n+2)
for i in range(2, n+1):
    fac[i] = fac[i-1] * i % mod
inv[n] = pow(fac[n], mod-2, mod)
for i in range(n-1, 1, -1):
    inv[i] = inv[i+1] * (i+1) % mod
    
ans = 0
for i in range(n+1):
    for j in range(n+1):
        if a*i + b*j > k: break
        if a*i + b*j == k:
          ans += comb(n, i) * comb(n, j)
print(ans % mod)

### FIXED CODE ###

mod = 998244353

def comb(n, r):
    if 2 * r > n: return comb(n, n-r)
    return fac[n] * inv[r] * inv[n-r] % mod

n, a, b, k = map(int, input().split())

fac = [1] * (n+2)
inv = [1] * (n+2)
for i in range(2, n+1):
    fac[i] = fac[i-1] * i % mod
inv[n] = pow(fac[n], mod - 2, mod)
for i in range(n-1, 1, -1):
    inv[i] = inv[i + 1] * (i + 1) % mod

ans = 0
for i in range(n+1):
    Num = (k-a*i)
    if (0 <= Num//b) and (Num//b <= n) and (Num%b == 0):
      j = Num//b 
      ans += comb(n, i) * comb(n, j) 
print(ans%mod)
### BUGGY CODE ###

import itertools
n,a,b = [int(x) for x in input().split()]

r = range(a,b+1)
tmp = []
ans = 0

if a == b:
    print(1)
elif n == 1:
    print(0)
else:
    for v in itertools.combinations_with_replacement(r, n-2):
        if not sum(v) in tmp:
            ans += 1
            tmp.append(sum(v))

    print(ans)

### FIXED CODE ###

n,a,b = [int(x) for x in input().split()]

if a > b:
    print(0)
elif n == 1:
    if a != b:
        print(0)
    else:
        print(1)
else:
    print((b-a)*(n-2)+1)
### BUGGY CODE ###

K,S=map(int,input().split())
K+=1
ans=0
for i in range(K):
  for j in range(K):
    if i+j>S :
      break
    for k in range (K):
      if i+j+k==S:
        ans+=1
print(ans)

### FIXED CODE ###

K,S=map(int,input().split())
ans=0
#a=max(0,S-2*K)
for i in range(K+1):
  for j in range(K+1):
    if i+j+K>=S and i+j<=S :
      ans+=1

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

from collections import defaultdict, deque


N = int(input())
d = defaultdict(int)
for i in range(N):
    d[i+1] = int(input())

#print(d)

q = []
q.append(1)

point = 1
count = 1

while True:
    if d[point] in q:
        print(-1)
        break
    if d[point] == 2:
        print(count)
        break
        
    q.append(d[point])
    point = d[point]
    count += 1

### FIXED CODE ###

from collections import defaultdict, deque
import sys

N = int(input())
d = defaultdict(int)
for i in range(N):
    d[i+1] = int(input())

#print(d)

q = deque()
q.append(1)

point = 1
count = 1

while N > 0:
    if d[point] == 2:
        print(count)
        sys.exit()
        
    q.append(d[point])
    point = d[point]
    count += 1
    N -= 1

print(-1)
### BUGGY CODE ###

n, x, y = map(int, input().split())

edges = [[] for _ in range(n)]
for i in range(n-1):
   edges[i].append(i+1)
   edges[i+1].append(i)

edges[x-1].append(y-1)
edges[y-1].append(x-1)

def bfs(v):
   dist = [-1] * n
   dist[v] = 0
   visit = [v]
   c = 1
   while visit:
      next = []
      for i in visit:
         for j in edges[i]:
            if dist[j] == -1:
               dist[j] = c
               next.append(j)
      visit = next
      c += 1

   return dist

minpath = []
for i in range(n):
   minpath.append(bfs(i))

for k in range(1, n):
   ans = 0
   for i in range(n):
      for j in range(i+1, n):
         if minpath[i][j] == k:
            ans += 1
   print(ans)


### FIXED CODE ###

n, x, y = map(int, input().split())

edges = [[] for _ in range(n)]
for i in range(n-1):
   edges[i].append(i+1)
   edges[i+1].append(i)

edges[x-1].append(y-1)
edges[y-1].append(x-1)

def bfs(v):
   dist = [-1] * n
   dist[v] = 0
   visit = [v]
   c = 1
   while visit:
      next = []
      for i in visit:
         for j in edges[i]:
            if dist[j] == -1:
               dist[j] = c
               next.append(j)
      visit = next
      c += 1

   return dist

minpath = []
for i in range(n):
   minpath.extend(bfs(i))

from collections import Counter
cnt = Counter(minpath)

for k in range(1, n):
   print(cnt[k]//2)
### BUGGY CODE ###

from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
th = Counter(st[:n])["W"] + Counter(st[n+1:])["E"]
previous = st[0]
for i in range(1,n):
    temp = ma[::-1][0]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
    if(th-(n-1) > min(ma)):
        break
print(min(ma))

### FIXED CODE ###

from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])
### BUGGY CODE ###

def main():
    N = int(input())
    S = input()
    # N = 39
    # S = 'RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB'
    
    ######### Index
    mix = []
    for i in range(len(S)):
        for j in range(i+1, len(S)):
            for k in range(j+1, len(S)):
                s = ''.join(sorted([S[i], S[j], S[k]]))
                if s == 'BGR':
                    mix.append([i, j, k])
    
    C = 0
    out = 0

    
    # print('----------------')
    for i, j, k in mix:
        # if S[i] != 'R' or S[j] != 'G' or S[k] != 'B':
        # print('aaa:', S[i], S[j], S[k])
        
        if abs(j - i) != abs(k - j):
            if (S[i] != S[j]) and (S[i] != S[k]) and (S[k] != S[j]):
            
                
                out += 1
        # else:
        #     print('out:', i, j, k, S[i], S[j], S[k])


    print(out)


    
main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(300000)
from collections import defaultdict
 
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
 
 
N = I()
S = input()

# N = 39
# S = 'RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB'
 
d = defaultdict(int)
for c in S:
    d[c] += 1
plus = d['R'] * d['G'] * d['B']

# print(plus)
 
minus = 0
for j in range(1, N - 1):
    for l in range(1, N):
        i, k = j - l, j + l
        if i < 0 or k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            minus += 1
 
print(plus - minus)
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))

array = []
index = 0

for i in range(len(P)-K+1):
    s = sum(P[i:i+K])
    if s >= index:
        index = s
        array = P[i:i+K]


ans = 0
for i in range(K):
    s = array[i]*(array[i]+1)/2
    ans += s / array[i]

print(ans)




### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))


kitaiti = {}

k = 1.0
for i in range(1, 1001):
    kitaiti[i] = k
    k += 0.5

index = 0

for i in range(K):
    index += kitaiti[P[i]]

s = index
ans = index

for i in range(1, len(P)-K+1):
    s = index - kitaiti[P[i-1]] + kitaiti[P[i+K-1]]
    if s > ans: ans = s
    index = s
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
pl = list(map(int, input().split()))
pl_max = 0
num_max = 0
s = 0
ans = 0
for m in range(n - k + 1):
    if pl_max < sum(pl[m:m + k]):
        pl_max = sum(pl[m:m + k])
        num_max = m
for i in range(num_max, num_max + k):
    for j in range(1, pl[i] + 1):
        s += j
    ans += s / pl[i]
    s = 0
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
res = tmp
for i in range(n - k):
    tmp -= p[i]
    tmp += p[i + k]
    res = max(res, tmp)
print((res + k) / 2)
### BUGGY CODE ###

# 正解ではない

from queue import PriorityQueue


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for i in range(H)]
    q = PriorityQueue()
    q.put((0, (Ch - 1, Cw - 1)))

    answer = resolve(q, S, (Dh - 1, Dw - 1), H, W)
    print(answer)


def resolve(q, S, D, H, W):
    is_empty = True
    while not q.empty():
        worp_count, (x, y) = q.get()
        if S[x][y] == '/':
            continue
        S[x][y] = '/'
        is_empty = False

        if (x, y) == D:
            return worp_count

        for i, j in [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)]:
            if 0 <= i < H and 0 <= j < W and S[i][j] == '.':
                q.put((worp_count, (i, j)))

        for i, j in [(a, b) for a in range(-2, 3) for b in range(-2, 3)]:
            if 0 <= x + i < H and 0 <= y + j < W and S[x + i][y + j] == '.':
                q.put((worp_count + 1, (x + i, y + j)))

    if is_empty:
        return -1

    return resolve(q, S, D, H, W)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    d = [[-1 for _ in range(W)] for _ in range(H)]

    q = deque([])
    q.appendleft((0, Ch - 1, Cw - 1))

    while len(q):
        worp_count, x, y = q.popleft()

        if d[x][y] != -1:
            continue
        d[x][y] = worp_count

        for i, j in ((a, b) for a in range(-2, 3) for b in range(-2, 3)):
            nx = x + i
            ny = y + j
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                if i == 0 and j == 0:
                    continue
                elif abs(i) + abs(j) == 1:
                    q.appendleft((worp_count, nx, ny))
                else:
                    q.append((worp_count + 1, nx, ny))

    print(d[Dh - 1][Dw - 1])


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

# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0

for i in range(min(p),max(p)+1):
	arc=[z for z in p if z>=i]
	abc=[z for z in p if z<i]
	if len(arc)==len(abc):cnt+=1
	if len(arc)<len(abc):break

print (cnt)



### FIXED CODE ###

# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0

p=sorted(p)

if p[n//2]!=p[(n//2)-1]:
	cnt=p[n//2]-p[(n//2)-1]



print (cnt)
### BUGGY CODE ###

N = int(input())
S = []

for i in range(N):
    S += [input()]

S_KEYS = set(S)

ANS = []

for key in S_KEYS:
    ANS +=[S.count(key)]

n= (max(ANS))

ANS = []
for key in S_KEYS:
    if S.count(key) == n:
        ANS +=[key]

ANS= sorted(ANS)
 
for key in ANS:
        print(key)


### FIXED CODE ###

N = int(input())
S = []

dic_={}
n = 1

for i in range(N):
    a = input()
    if a in dic_.keys():
        b = dic_.get(a) + 1
        dic_.update({a: b})
        if n < b:
            n = b
    else:
        dic_.update({a: 1})

ANS = []

for i in dic_:
    if dic_.get(i) == n:
        ANS += [i]

ANS = sorted(ANS)

for key in ANS:
        print(key)
### BUGGY CODE ###

n=int(input())
h_list=list(map(int,input().split()))
cnt=0
mx=0
for i in range(len(h_list)):
    num=i
    cnt=0
    for num in range(num,len(h_list)-1):
        if h_list[num]>=h_list[num+1]:
            cnt+=1
        else:
            break
    if cnt>mx:
        mx=cnt
print(mx)

### FIXED CODE ###

n=int(input())
h_list=list(map(int,input().split()))
cnt=0
mx=0
i=0
while i<len(h_list):
    if mx>=(len(h_list)-i):
        break
    num=i
    cnt=0
    for j in range(num,len(h_list)-1):
        if h_list[j]>=h_list[j+1]:
            cnt+=1
        else:
            i=j
            break
    i+=1
    if cnt>mx:
        mx=cnt
print(mx)
### BUGGY CODE ###

from _collections import deque

_temp = deque([])
my_max = []

size = int(input().rstrip())
for i in range(size):
    try:
        _temp.append(int(input()))
    except EOFError:
        continue



for val in list(_temp)[:-1]:
    v = _temp.popleft()
    my = max(_temp) - v

    if len(my_max) == 0:
        my_max.append(my)
    else:
        if my > max(my_max):
            my_max.append(my)

print(max(my_max))

### FIXED CODE ###

_temp = []

size = int(input().rstrip())
for i in range(size):
    try:
        _temp.append(int(input()))
    except EOFError:
        continue

my_max = -20000000000000
my_min = _temp.pop(0)


for val in _temp:
    my_max = max(my_max, (val - my_min))
    my_min = min(my_min, val)

print(my_max)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
dp = [[0 for _ in range(21)] for _ in range(n+1)]
def binl(x, accl):
    if len(accl) == 20:
        return accl
    else:
        accl.append(x%2)
        return binl(x//2, accl)
ans = 0
for i in range(1, n+1):
    m = i
    b = binl(a[i-1], [])
    for j in range(20):
        if b[j] == 1:
            dp[i][j] = i
            m = min(m, i - dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
    dp[i][20] = min(m, dp[i-1][20]+1)
    ans += dp[i][20]
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
l = 0
r = 0
count = 0
while(r < n or l < n):
    if r < n and (cum[r] - cum[l]) & a[r] == 0:
        r += 1
    else:
        count += r - l
        l += 1
print(count)