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

txt = list(input())
a = txt.pop(0)
temp = [a]
while(len(txt) != 0):
  #print(temp)
  a = txt.pop(0)
  if a == temp[-1]:
    if len(txt) >= 1:
      a += txt.pop(0)
      temp.append(a)
    else:
      temp[-1] += a
  #print(a)
  else:
    temp.append(a)
print(len(temp))

### FIXED CODE ###

txt = list(input())
a = txt[0]
count = 1
i = 1
while(i < len(txt)):
  #print(temp)
  if a != txt[i]:
    a = txt[i]
    i += 1
    count += 1
  else:
    if (len(txt)-i) >= 2:
      a = txt[i:i+1]
      i += 2
      count += 1
    else:
      break
print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import math
# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N > 1:
    for i in range(M):
        A.sort(reverse=True)
        A[0] = math.floor(A[0] * 0.5)
else:
    A[0] = math.floor(A[0] * (1 / pow(2, M)))
print(sum(A))


### FIXED CODE ###

# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import heapq

# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
    A[i] *= -1

heapq.heapify(A)

for _ in range(M):
    heapq.heappush(A, ((heapq.heappop(A) * -1) >> 1) * -1)

print(sum(A) * -1)
### BUGGY CODE ###

# -*- coding:utf-8 -*-

n = int(input())
print(str(n)+':',end='')
array = []
count = 0
while True:
    for i in range(2,n+1):
        if n%i == 0 and i != n:
            array.append(i)
            n = int(n/i)
            break
        if i == n:
            count += 1
            break
    if count == 5:
        break
array.append(n)
for i in range(len(array)):
    print(' ',array[i],sep = '',end='')
print('')

### FIXED CODE ###

# -*- coding:utf-8 -*-

n = int(input())
print(str(n)+':',end='')
array = []
count = 0
while True:
    if n == 999993031:
        break
    for i in range(2,n+1):
        if n%i == 0 and i != n:
            array.append(i)
            n = int(n/i)
            break
        if i == n:
            count += 1
            break
    if count == 24:
        break

array.append(n)
for i in range(len(array)):
    print(' ',array[i],sep = '',end='')
print('')
### BUGGY CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
tmp = 1
route = [tmp]

for i in range(1, k + 1):
    tmp = A[tmp - 1]
    if tmp in route:
        left = route.index(tmp)
        right = len(route)
        idx = left + (k - left) % (right - left)
        print(route[idx])
        break
    else:
        route.append(tmp)
        continue
else:
    print(tmp)

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
tmp = 1
route = [tmp]
edge = {tmp}

for i in range(1, k + 1):
    tmp = A[tmp - 1]
    if tmp in edge:
        left = route.index(tmp)
        right = len(route)
        idx = left + (k - left) % (right - left)
        print(route[idx])
        break
    else:
        route.append(tmp)
        edge.add(tmp)
        continue
else:
    print(tmp)
### BUGGY CODE ###

import numpy as np
n=int(input())
ds=list(map(int,input().split()))
nds=np.array(ds)
c=0
for k in range(min(ds),max(ds)+1):
    l=sum(np.where(nds<k,1,0))
    if l==n-l:
        c+=1
print(c)


### FIXED CODE ###

n=int(input())
ds=list(map(int,input().split()))
ds.sort()
print(ds[n//2]-ds[n//2-1])
### BUGGY CODE ###

n = int(input())
a = 1
b = 1
mx = 10 ** 10
while (a <= b):
    if n % a == 0:
        b = int(n / a)
        mx = min(mx, max(a, b))
    a += 1
print(len(str(mx)))

### FIXED CODE ###

n = int(input())
a = 1
b = 1
mx = 10 ** 10
while (a <= b and a <= 10**5):
    if n % a == 0:
        b = int(n / a)
        mx = min(mx, max(a, b))
    a += 1
print(len(str(mx)))
### BUGGY CODE ###

A, B = map(int, input().split())

i = max(A, B)

while True:
  
  if i % A == 0 and i % B == 0:
    print(i)
    exit()
    
  i += 1
  


### FIXED CODE ###

import numpy as np

A, B = map(int, input().split())

print(np.lcm(A, B))
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()

for i in range(q):
    l,r=map(int,input().split())
    t=s[l-1:r]
    print(t.count('AC'))


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
t=[0]*n
a=0
for i in range(n-1):
    if s[i:i+2]=='AC':
        a+=1
    t[i+1]=a
for i in range(q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

from itertools import product
def main():
    d, g = map(int, input().split())
    score_set = []
    score_set_qnum = []
    for i1 in range(1, d + 1):
        kazu, bonus = map(int, input().split())
        score_p = []
        for i2 in range(kazu):
            score_p.append(i1 * 100 * i2)
        score_p.append(i1 * 100 * kazu + bonus)
        score_set.append(score_p)
        score_set_qnum.append(range(kazu + 1))
    score_set_pat = tuple(product(*score_set))
    score_set_qnum_pat = tuple(product(*score_set_qnum))

    inf = float('inf')
    r = inf
    for sset, ssetq in zip(score_set_pat, score_set_qnum_pat):
        sset_sum = sum(sset)
        if sset_sum >= g:
            r = min(r, sum(ssetq))
    print(r)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from itertools import product
from math import ceil
def main():
    d, g = map(int, input().split())
    scoremax_set = []
    numq_set = []
    for i1 in range(1, d + 1):
        kazu, bonus = map(int, input().split())
        scoremax_set.append(i1 * 100 * kazu + bonus)
        numq_set.append(kazu)
    score_get_pat = tuple(product((1,0), repeat=d))

    inf = float('inf')
    r = inf

    for sgpe in score_get_pat:
        score = 0
        q_num = 0
        for j1, s in zip(sgpe, scoremax_set):
            score += j1 * s
        for j2, num in zip(sgpe, numq_set):
            q_num += j2 * num
        if score >= g:
            r = min(r, q_num)
        else:
            sgpe_l = [i for i, x in enumerate(sgpe) if x == 0]
            score_plus = (sgpe_l[-1]+1)*100 * (numq_set[sgpe_l[-1]] - 1)
            if score + score_plus >= g:
                q_num += ceil((g - score) / ((sgpe_l[-1]+1)*100))
                r = min(r, q_num)
    print(r)


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

import sys

def input():
    return sys.stdin.readline()[:-1]


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

for _ in range(k):
    b_li = [0 for _ in range(n)]
    for i in range(n):
        l = max(0, i-a_li[i])
        r = min(n-1, i+a_li[i])
        for j in range(l, r+1):
            b_li[j] += 1
    a_li = b_li
    
print(' '.join(map(str, a_li)))

### FIXED CODE ###

import sys

def input():
    return sys.stdin.readline()[:-1]


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

if k>=42:
    print(*[n]*n)
    exit()

for i in range(k):
    b = [0] * n
    for j in range(n):
        l = max(0, j-a_li[j])
        r = min(n-1, j+a_li[j])
        b[l] += 1
        if (r+1<n):
            b[r+1] -= 1
    for j in range(n-1):
        b[j+1] += b[j]
    a_li = b
print(*a_li)
### BUGGY CODE ###

S = input()
Q = int(input())

hanten = 0

for i in range(Q):
    q = input().split()
    
    if q[0] == "1":
        hanten += 1
    else:
        if hanten % 2 == 0:
            if q[1] == "1":
                S = q[2] + S
            else:
                S = S + q[2]
        else:
            if q[1] == "1":
                S = S + q[2]
            else:
                S = q[2] + S

if hanten % 2 == 0:
    print(S)
else:
    print(S[::-1])

### FIXED CODE ###

S = input()
Q = int(input())

hanten = 0
saki = ""
ato = ""

for i in range(Q):
    q = input().split()
    
    if q[0] == "1":
        hanten += 1
    else:
        if hanten % 2 == 0:
            if q[1] == "1":
                saki += q[2]
            else:
                ato += q[2]
        else:
            if q[1] == "1":
                ato += q[2]
            else:
                saki += q[2]

if hanten % 2 == 0:
    for i in range(len(saki)):
        print(saki[-i-1], end="")
    print(S, end="")
    print(ato)
else:
    for i in range(len(ato)):
        print(ato[-i-1], end="")
    for i in range(len(S)):
        print(S[-i-1], end="")
    print(saki)
### BUGGY CODE ###

from collections import deque
N, X, Y = map(int, input().split())

X -= 1
Y -= 1

q = deque()

ans = [0] * N

def BFS(x, cnt):
    if dist[x] != (N + 1):
        return
    cnt += 1
        
    dist[x] = cnt
    if x + 1 < N:
        q.append((x + 1, cnt))
    if x - 1 >= 0:
        q.append((x - 1, cnt))
    if x == X:
        q.append((Y, cnt))
    if x == Y:
        q.append((X, cnt))


for x in range(N):
    dist = [N + 1] * N
    q.append((x, -1))
    while q:
        BFS(*q.popleft())

    for i in range(N):
        ans[dist[i]] += 1

for x in range(1, N):
    print(ans[x] // 2)






### FIXED CODE ###

from collections import deque
N, X, Y = map(int, input().split())

X -= 1
Y -= 1

q = deque()

ans = [0] * N

def BFS(x, cnt):
    if dist[x] != (N + 1):
        return
    cnt += 1
        
    dist[x] = cnt
    if x + 1 < N:
        q.append((x + 1, cnt))
    if x - 1 >= 0:
        q.append((x - 1, cnt))
    if x == X:
        q.append((Y, cnt))
    if x == Y:
        q.append((X, cnt))


for x in range(N):
    dist = [N + 1] * N
    q.append((x, -1))
    while q:
        BFS(*q.popleft())

    for i in range(N):
        ans[dist[i]] += 1

for x in range(1, N):
    print(ans[x] // 2)
### BUGGY CODE ###

import sys

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

if k > max(a) :
  print('IMPOSSIBLE')
  sys.exit()
if k in a :
  print('POSSIBLE')
  sys.exit()
  
ans = 'IMPOSSIBLE'
c = 0
for i in range(n-1) :
  a1 = a[i]
  for j in range(i+1,n) :
    a2 = a[j]
    if not abs(a1-a2) in a :
      c = 1
  if c == 1 :
    ans = 'POSSIBLE'
    break

print(ans)

### FIXED CODE ###

import sys
import fractions

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

if k > max(a) :
  print('IMPOSSIBLE')
  sys.exit()
if k in a :
  print('POSSIBLE')
  sys.exit()
  
g = fractions.gcd(a[0],a[1])
for i in range(2,n) :
  g = fractions.gcd(g,a[i])
  
if k%g == 0 :
  print('POSSIBLE')
else :
  print('IMPOSSIBLE')
### BUGGY CODE ###

def resolve():
	g = [list(map(int, input().split())) for _ in range(3)]
	t = [[None]*3 for _ in range(3)]
	m = max(map(max, g))
	for a in range(m+1):
		for b in range(m+1):
			for c in range(m+1):
				for d in range(m+1):
					for e in range(m+1):
						for f in range(m+1):
							y = [a, b, c]
							x = [d, e, f]
							ans = True
							for i in range(3):
								for j in range(3):
									if g[i][j] != y[i] + x[j]:
										ans = False
							if ans:
								print('Yes')
								return
	print('No')
resolve()

### FIXED CODE ###

def resolve():
	g = [list(map(int, input().split())) for _ in range(3)]
	m = max(map(max, g))
	for a in range(m+1):
		for b in range(m+1):
			for c in range(m+1):
				y = [a, b, c]
				x = [g[i][i] - y[i] for i in range(3)]
				ans = True
				for i in range(3):
					for j in range(3):
						v = y[i] + x[j]
						if g[i][j] != v:
							ans = False
				if ans:
					print('Yes')
					return

	print('No')
resolve()
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

MOD = 10 ** 9 + 7
def my_pow(base, n, mod):
    if n == 0:
        return 1
    x = base
    y = 1
    while n > 1:
        if n % 2 == 0:
            x *= x
            n //= 2
        else:
            y *= x
            n -= 1
        x %= mod
        y %= mod
    return x * y % mod

N = int(input())

adj = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1    
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

ans = 0
def dfs(v, p):
    global ans
    subs = []
    res = 1
    for u in adj[v]:
        if u == p:
            continue
        val = dfs(u, v)
        res += val
        subs.append(val)
    # add sub-tree on the parent side
    if p != -1:
        subs.append(N - res)
    now = (2 ** (N - 1)) - 1 # N - 1 means that it chooses freelye other than v
    for sub in subs:
        now -= ((2 ** sub) - 1)
    ans += now
    ans %= MOD
    return res

dfs(0, -1)
print(ans * my_pow(2 ** N, MOD - 2, MOD) % MOD)

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

MOD = 10 ** 9 + 7
def my_pow(base, n, mod):
    if n == 0:
        return 1
    x = base
    y = 1
    while n > 1:
        if n % 2 == 0:
            x *= x
            n //= 2
        else:
            y *= x
            n -= 1
        x %= mod
        y %= mod
    return x * y % mod

N = int(input())

adj = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1    
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

pows = [1] * N
for i in range(1, N):
    pows[i] = (pows[i - 1] * 2) % MOD

ans = 0
def dfs(v, p):
    global ans
    subs = []
    res = 1
    for u in adj[v]:
        if u == p:
            continue
        val = dfs(u, v)
        res += val
        subs.append(val)
    # add sub-tree on the parent side
    if p != -1:
        subs.append(N - res)
    now = pows[N - 1] - 1 # N - 1 means that it chooses freelye other than v
    for sub in subs:
        now -= pows[sub] - 1
    ans += now
    ans %= MOD
    return res

dfs(0, -1)
print(ans * my_pow(2 ** N, MOD - 2, MOD) % MOD)
### BUGGY CODE ###

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
dots = XY[:]

import sys
INT_MAX = sys.maxsize

x_dots = [(x, y) for x, y in dots]
x_dots = sorted(x_dots)
y_dots = [(y, x) for x, y in dots]
y_dots = sorted(y_dots)
y_dots = [(x, y) for y, x in y_dots]

ans = INT_MAX
for i in range(N):
    for j in range(i+1, N):
        for k in range(N):
            for l in range(k+1, N):
                #print("----")
                #print(x_dots[i:j+1])
                #print(y_dots[k:l+1])
                intersection = (set(x_dots[i:j+1]) & set(y_dots[k:l+1]))
                if len(intersection) >= K:
                    xl = x_dots[i:j+1][0][0]
                    xr = x_dots[i:j+1][-1][0]
                    yl = y_dots[k:l+1][0][1]
                    yr = y_dots[k:l+1][-1][1]
                    area = (xl-xr) * (yl-yr)
                    
                    ans = min(ans, area)
print(ans)
                
                

### FIXED CODE ###

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)
### BUGGY CODE ###

n=int(input())
a=tuple(map(int,input().split()))
for cnt in range(len(a)):
    num=0
    for j in a[cnt:]:
        if j == cnt + 1:
            num += 1
    print(num)
print(0)


### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for n in range(N):
  print(count[n+1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
s = input()
q = int(input())
K = list(map(int,input().split()))

# print(s)

for i in range(q):
    ans = 0
    k = K[i]
    D = [[0] * 3 for j in range(n)]
    for j in range(n):
        D[j][:] = D[j-1][:]

        if j-k >= 0:
            if s[j-k] == "D":
                D[j][0] -= 1
                D[j][2] -= D[j][1]
            elif s[j-k] == "M":
                D[j][1] -= 1

        if s[j] == "D":
            D[j][0] += 1
        elif s[j] == "M":
            D[j][1] += 1
            D[j][2] += D[j][0]
        elif s[j] == "C":
            ans += D[j][2]
    print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = input()
    q = int(input())
    K = list(map(int,input().split()))
    # print(s)

    for i in range(q):
        ans = 0
        d = 0
        m = 0
        dm = 0
        k = K[i]
        for j in range(n):

            if j-k >= 0:
                if s[j-k] == "D":
                    d -= 1
                    dm -= m
                elif s[j-k] == "M":
                    m -= 1

            if s[j] == "D":
                d += 1
            elif s[j] == "M":
                m += 1
                dm += d
            elif s[j] == "C":
                ans += dm
        print(ans)

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

from math import ceil
from bisect import bisect_right

def update(x, v):
  while x <= N:
    fw[x] += v
    x += x & -x

def s(x):
  res = 0
  while x:
    res += fw[x]
    x -= x & -x
  return res

def change(l, r, a):
  update(l, a)
  update(r + 1, -a)


N,D,A = map(int,input().split())
monsters = sorted([list(map(int,input().split())) for _ in range(N)])

fw = [0 for _ in range(N + 1)]

ans = 0
for i in range(N):
  h = s(i + 1) - s(0)
  if monsters[i][1] + h > 0:
    num_bomb = ceil((monsters[i][1] + h) / A)
    ans += num_bomb

    k = bisect_right(monsters, [monsters[i][0] + 2*D, 10**9])
    change(i + 1, k, -(num_bomb * A))
    
print(ans)


### FIXED CODE ###

from math import ceil
from collections import deque

N,D,A = map(int,input().split())
monsters = sorted([list(map(int,input().split())) for _ in range(N)])

q = deque([])
s = 0

ans = 0
for i in range(N):
  while len(q) > 0 and q[0][0] < monsters[i][0]:
    s -= q[0][1]
    q.popleft()

  h = monsters[i][1] - s * A
  if h > 0:
    num_bombs = ceil(h / A)

    q.append((monsters[i][0] + 2 * D, num_bombs))
    s += num_bombs
    ans += num_bombs
    
print(ans)
### BUGGY CODE ###

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

ans = 1
for i in a:
    ans *= i

if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

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

if 0 in a:
    print(0)
    exit(0)

ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit(0)

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

n=int(input())
list=[[0]*n]
list=input().split()
for i in range(n):
  list[i]=int(list[i])

yen=1000
stock=0
keikou=0
for i in range(1,n):
  if list[i]-list[i-1]<=0:
    keikou+=1
if keikou!=n-1:
  list2=sorted(list)
  list.index(list2[0])
  
  for t in range(1,n):
    if list[t]-list[t-1]>=0:
      while(yen>=list[t-1]):
        yen-=list[t-1]
        stock+=1
      yen+=list[t]*stock
      stock=0
print(yen)

### FIXED CODE ###

n=int(input())
list=[[0]*n]
list=input().split()
for i in range(n):
  list[i]=int(list[i])

yen=1000
stock=0
keikou=0
for i in range(1,n):
  if list[i]-list[i-1]<=0:
    keikou+=1
if keikou!=n-1:
  for t in range(1,n):
    if list[t]-list[t-1]>=0:
      stock+=int(yen/list[t-1])
      yen-=list[t-1]*int(yen/list[t-1])
      yen+=list[t]*stock
      stock=0
print(yen)
### BUGGY CODE ###

import sys
from collections import Counter as cc
# from functools import lru_cache
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    sys.setrecursionlimit(10**4)
    n = ii()
    a = li()
    c = cc(a)
    N = sum(c.values())
    
    # @lru_cache
    def dfs(x, y, z):
        if x== 0 and y == 0 and z == 0:
            return 0
        tmp = 1
        if x > 0:
            tmp += dfs(x-1, y, z)*x/N
        if y> 0:
            tmp += dfs(x+1, y-1, z)*y/N
        if z > 0:
            tmp += dfs(x, y+1, z-1)*z/N
        tmp *= N/(x+y+z)
        return tmp
    
    print(dfs(c[1], c[2], c[3]))

    

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import Counter as cc
from numba import njit
import numpy as np

def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

# sys.setrecursionlimit(10**4)
n = ii()
a = li()
c = cc(a)
N = sum(c.values())
cache = np.full((N+1, N+1, N+1), -1, dtype=float)
cache[0][0][0] = 0
@njit(cache=True)
def dfs(x, y, z, N, cache):
    if x+y+z==0:
        return 0
    if cache[x][y][z]>=0:
        return cache[x][y][z]
    tmp = 1
    if x > 0:
        tmp += dfs(x-1, y, z,N, cache)*x/N
    if y > 0:
        tmp += dfs(x+1, y-1, z, N, cache)*y/N
    if z > 0:
        tmp += dfs(x, y+1, z-1, N, cache)*z/N
    tmp *= N/(x+y+z)
    cache[x][y][z] = tmp
    return tmp

dfs(c[1], c[2], c[3], N, cache)
print(cache[c[1]][c[2]][c[3]])
### BUGGY CODE ###

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

ans=[]

for i in range(1,n):
    snuke=sum(a[0:i])
    raccoon=sum(a)-snuke
    ans.append(abs(snuke-raccoon))

print(min(ans))


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
X=sum(a)

ans=[]
snuke=0

for i in range(n-1):
    snuke+=a[i]
    ans.append(abs(X-2*snuke))

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

def main():
    n, k = [int(i) for i in input().split()]
    s = [int(i) for i in list(input())]
    table = []
    now = 1
    cnt = 0
    for i in range(n):
        if s[i] == now:
            cnt += 1
        else:
            table.append(cnt)
            cnt = 1
            now ^= 1 # 0　と 1 の切り替え
    if cnt != 0:
        table.append(cnt)
    if len(table)%2 == 0:
        # 奇数で終わらせれば、1 で終わったことになる
        table.append(0)
    ans = 0
    l, r = 0, min(len(table)-1, 2*k)
    while r < len(table):
        ans = max(ans, sum(table[l:r+1]))
        l += 2
        r += 2
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, k = [int(i) for i in input().split()]
    s = [int(i) for i in list(input())]
    table = []
    now = 1
    cnt = 0
    for i in range(n):
        if s[i] == now:
            cnt += 1
        else:
            table.append(cnt)
            cnt = 1
            now ^= 1 # 0　と 1 の切り替え
    if cnt != 0:
        table.append(cnt)
    if len(table)%2 == 0:
        # 奇数で終わらせれば、1 で終わったことになる
        table.append(0)
    ans = 0
    l = 0
    d = min(len(table), 2*k+1)
    r = l + d
    tmp = sum(table[l:r])
    while r <= len(table):
        ans = max(ans, tmp)
        if l < len(table):
            tmp -= table[l]
        l += 1
        if l < len(table):
            tmp -= table[l]
        l += 1
        r += 1
        if r <= len(table):
            tmp += table[r-1]
        r += 1
        if r <= len(table):
            tmp += table[r-1]
    print(ans)


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

N = int(input())
L = list(map(int,input().split(' ')))

L.sort()
#print(L)


cnt = 0
for i in range(N-2):
    highJ = 0
    for j in range(i+1,N-1):
        tmphighJ = max(j,highJ)
        for k in range(max(j+1,highJ+1),N):
            if L[k] < L[i]+L[j]:
                tmphighJ = k
            else:
                break
        highJ = max(j,tmphighJ)
        cnt+= tmphighJ - j
        #print(i,j,highJ,cnt)

print(cnt)
            

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split(' ')))

L.sort()
#print(L)

cnt = 0
order =0
for i in range(N-2):
    highJ = 0
    for j in range(i+1,N-1):
        tmphighJ = max(j,highJ)
        for k in range(max(j+1,highJ+1),N):
            order+=1
            if L[k] < L[i]+L[j]:
                tmphighJ = k
            else:
                break
        highJ = max(j,tmphighJ)
        cnt+= highJ - j
        #print(i,j,highJ,cnt)

print(cnt)
#print(order)