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

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

# 入力を変数に格納
count = int(input())
num_list = [int(i) for i in input().split()]

result = 0
for i in range(count):
    # 合計初期化
    num_sum = 0
    # 前から順番に足していって0になるやつを探す
    for num in num_list:
        num_sum += num
        
        if num_sum == 0:
            result += 1
    # 最初の要素を削除
    num_list.pop(0)

print(result)

### FIXED CODE ###

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

"""
参考：https://img.atcoder.jp/agc023/editorial.pdf
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def nCr(n, r):
    # 10C7 = 10C3
    r = min(r, n-r)
    return factorial(n) // (factorial(r) * factorial(n-r))

N = INT()
aN = LIST()

sm = [0] * (N+1)
for i in range(N):
    sm[i+1] = sm[i] + aN[i]

c = Counter(sm)
ans = 0
for k, v in c.items():
    if v >= 2:
        ans += nCr(v, 2)
print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

graph = [[float('inf')]*H*W for _ in range(H*W)]
for i in range(H*W):
    graph[i][i]=0
nv = [(-1, 0), (1, 0), (0, -1), (0, 1)]

for h in range(H):
    for w in range(W):
        if S[h][w]=='.':
            for nx, ny in nv:
                if H <= h+nx or h+nx < 0 or W <= w+ny or w+ny < 0:
                    continue
                if S[h+nx][w+ny]=='.':
                    graph[W*h+w][W*(h+nx)+(w+ny)] = 1
                    graph[W*(h+nx)+(w+ny)][W*h+w] = 1

for k in range(H*W):
    for i in range(H*W):
        for j in range(H*W):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
ans = 0
for i in range(H*W-1):
    for j in range(i+1, H*W):
        if graph[i][j] != float('inf'):
            ans = max(ans, graph[i][j])
print(ans)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
area = ['#']*(W+2)
for i in range(H):
    area += ['#']+list(input())+['#']
area += ['#']*(W+2)
H+=2
W+=2
move = [-1, 1, W, -W]
ans = 0
for i in range(H):
    for j in range(W):
        st = W*i+j
        if area[st]=='#': continue
        dq = deque([])
        dist = [-1]*(H*W)
        dq.append(st)
        dist[st] = 0
        while dq:
            now = dq.popleft()
            for dx in move:
                nxt = now+dx
                if dist[nxt]>=0 or area[nxt]=='#': continue
                dist[nxt] = dist[now]+1
                ans = max(ans, dist[nxt])
                dq.append(nxt)
print(ans)
### BUGGY CODE ###

import math
L, R = map(int, input().split())
R=min(R,(L+2019)*2)
m=2018
for i in range(L,R+1):
  for j in range(i,R+1):
    if i==j:
      continue
    if (i*j)%2019<m:
      m=(i*j)%2019
print(m)

### FIXED CODE ###

import math
L, R = map(int, input().split())
R=min(R,L+2019)
m=2018
for i in range(L,R+1):
  for j in range(i,R+1):
    if i==j:
      continue
    if (i*j)%2019<m:
      m=(i*j)%2019
print(m)
### BUGGY CODE ###

N = int(input())
cyapa = []
for i in range (1,6):
    cyapa.append(int(input()))
city1 = N
city2 = 0
city3 = 0
city4 = 0
city5 = 0
city6 = 0
mi = 0
while city6 < N:
    city6 = city6 + min(city5,cyapa[4])
    city5 = city5 + min(city4,cyapa[3]) - min(city5,cyapa[4])
    city4 = city4 + min(city3,cyapa[2]) - min(city4,cyapa[3])
    city3 = city3 + min(city2,cyapa[1]) - min(city3,cyapa[2])
    city2 = city2 + min(city1,cyapa[0]) - min(city2,cyapa[1])
    city1 = city1 - min(city1,cyapa[0])
    mi = mi + 1
print(mi)

### FIXED CODE ###

N = int(input())
cyapa = []
for i in range (1,6):
    cyapa.append(int(input()))
kasu = min(cyapa)
if kasu >= N:
    ans = 5
else:
    ans = 5 + (N-1)//kasu
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(210000)
input = sys.stdin.readline

N = int(input())
A = [int(input()) for i in range(N)]
Ad = [0] *N

for i in range(N):
    tmp = A[i]
    A[i] = 0
    print(max(A))
    A[i] = tmp

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
A_reverse = sorted(A)

for i in range(N):
    if A[i] == A_reverse[-1]:
        print(A_reverse[-2])
    else:
        print(A_reverse[-1])
### BUGGY CODE ###

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

s = 0
m=10**9+7
for i in range(n-1):
    ss=0
    for j in range(i+1,n):
        ss+=a[j]
    ss=ss%m
    s+=(a[i]*ss)%m


print(s%m)



### FIXED CODE ###


n = int(input())
mod = 1000000007
a = list(map(int,input().split()))
width = 0
ans = 0
for i in range(n):
    ans = (ans + a[i]*width)  % mod
    width = (width + a[i]) % mod

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

K = int(input())
firsta = 7 % K
if firsta == 0:
    print(1)
elif firsta == 77 % K:
    print(-1)
else:
    ans = 2
    preva = 77 % K
    while preva != firsta and preva != 0:
        preva = ((preva*10)+7) % K
        ans += 1
        if preva == firsta:
            ans = -1
    print(ans)
    

### FIXED CODE ###

K = int(input())
def check(k):
    aaa = 0
    prev = 7%k
    for i in range(0,k):
        aaa+=1
        if prev == 0:
            return(aaa)
        prev = (prev*10+7)%k
    return(-1)
print(check(K))
### BUGGY CODE ###

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

### FIXED CODE ###

s = input()
n = len(s)
dp = [1] + [0]*2019
now = 0
i = 1

for c in reversed(s):
    now = (now+i*int(c))%2019
    dp[now] += 1
    i *= 10
    i %= 2019

ans = sum([i*(i-1)/2 for i in dp])
print(int(ans))
### BUGGY CODE ###

from collections import deque
n,x,y = map(int,input().split())


graph = {}

for i in range(n):
    if(i == 0):
        graph[i] = [1]
    elif(i == n-1):
        graph[i] = [n-2]
    else:
        graph[i] = [i-1,i+1]


#print(graph)

xx = graph[x-1]
xx.append(y-1)
graph[x-1] = xx

yy = graph[y-1]
yy.append(x-1)
graph[y-1] = yy

#print(graph)

def bfs(graph,st):
    q = deque()
    q.append(st)
    dist = [-1]*n
    dist[st] = 0
    
    while len(q) > 0:
    # キューの先頭（左端）からnodeを取り出す
        v = q.popleft()
        
        for i in graph[v]:
            if (dist[i] != -1):
                continue
            dist[i] = dist[v] + 1;
            q.append(i)
    
    return dist

res = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    res[i] = bfs(graph,i)

#print(res)

for k in range(1,n):
    ress = 0
    for i in range(n):
        ress += res[i].count(k)
    
    
    print(ress//2)

### FIXED CODE ###

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


dic = {}
x = x-1
y = y-1
for i in range(n):
    for j in range(n):
        if(i == j):
            break

        nm = abs(j - i)
        if(abs(x-i) > abs(y-i)):
            lp = abs(y-i) + abs(x-j) + 1
        else:
            lp = abs(x-i) + abs(y-j) + 1
        
        k = min(nm,lp)
        if(k in dic):
            dic[k] += 1
        else:
            dic[k] = 1



for i in range(1,n):
    if not (i in dic):
        print(0)
    else:
        print(dic[i])
### BUGGY CODE ###

n=int(input())
a=[[0]*n]*n
l=[]

for i in range(n):
  a[i]=[int(x)-1 for x in input().split()]

t=0
f=True
while f==True:
  f=False
  for i in range(n):
    if len(a[i])==0:
      continue
    f=True
    j=a[i][0]
    if i<j:
      if i==a[j][0]:
        l.append(i)
        l.append(j)

  if f==False:
    break

  if len(l)!=0:
    t+=1
    for i in range(len(l)):
      a[l.pop(0)].pop(0)
  else:
    t = -1
    break
print(t)


### FIXED CODE ###

from collections import deque

def main():
  N=int(input())
  A=[deque(int(a)-1 for a in input().split()) for _ in range(N)]

  P,W=[0]*N,[-1]*N
  c=deque(range(N))

  while c:
    i=c.popleft()
    j=A[i].popleft()
    W[i]=j

    if W[j]==i:
      P[i]=P[j]=max(P[i],P[j])+1
      if A[i]:
        c.append(i)
      if A[j]:
        c.append(j)

  print(-1 if any(len(a) for a in A) else max(P))

main()
### BUGGY CODE ###

S=input()
x=0
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        a=int(S[i:j])
        if a%2019==0:
            x=x+1
print(x)   

### FIXED CODE ###

A=[0]*2019
s=input()
a=0
b=1
for i in range(len(s)):
    b=b%2019
    a=(a+int(s[len(s)-1-i])*b)%2019
    b=b*10
    A[a]+=1
x=A[0]
for j in range(2019):
    x+=int(A[j]*(A[j]-1)/2)
print(x)
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int, input().split()))) + [0]
 
memo = ['Y'] * (10**6+1)
count = 0
 
for i in range(N):
    if memo[A[i]] == 'N':
        continue
    for j in range(A[i], max(A)+1, A[i]):
        memo[j] = 'N'
    if A[i] == A[i+1]:
        continue
    
    count += 1
 
print(count)

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)
### BUGGY CODE ###

from collections import defaultdict

MAX = 40001


def main():
    N, Ma, Mb = [int(a) for a in input().split()]

    abc = [
        [int(a) for a in input().split()]
        for _ in range(N)
    ]

    dp = [
        [
            [MAX for b in range(10 * N + 1)]
            for a in range(10 * N + 1)
        ]
        for i in range(N)
    ]  # dp[i][a][b] = i番目までを使ってaグラムbグラムを作る最小コスト

    a, b, c = abc[0]
    dp[0][a][b] = c
    dp[0][0][0] = 0

    for i in range(1, N):
        a, b, c = abc[i]
        for j in range(10 * N):
            for k in range(10 * N):
                tukawanai = dp[i - 1][j][k]
                if j - a >= 0 and k - b >= 0 and dp[i - 1][j - a][k - b] != MAX:
                    tukau = dp[i - 1][j - a][k - b] + c
                    dp[i][j][k] = min(tukawanai, tukau)
                else:
                    dp[i][j][k] = tukawanai

    res = MAX
    l = dp[-1]
    for a in range(1,10 * N+1):
        aa = a * Mb
        if aa % Ma != 0:
            continue
        b = aa // Ma
        if b >= len(l[a]):
            continue
        c = l[a][b]
        res = min(res, c)

    if res == MAX:
        res = -1
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict

MAX = 40001


def main():
    N, Ma, Mb = [int(a) for a in input().split()]

    abc = [
        [int(a) for a in input().split()]
        for _ in range(N)
    ]

    dp = [
        [
            [MAX for b in range(10 * N + 1)]
            for a in range(10 * N + 1)
        ]
        for i in range(N)
    ]  # dp[i][a][b] = i番目までを使ってaグラムbグラムを作る最小コスト

    A, B, C = abc[0]
    # dp[0][a][b] = c
    # dp[0][0][0] = 0

    mem = {(0, A, B): C, (0, 0, 0): 0}

    def solve(i, a, b):
        if (i, a, b) in mem:
            return mem[(i, a, b)]
        if i == 0:
            return MAX
        ai, bi, ci = abc[i]
        tukawanai = solve(i - 1, a, b)
        if a - ai >= 0 and b - bi >= 0:
            pre = solve(i - 1, a - ai, b - bi)
            if pre != MAX:
                mem[(i, a, b)] = min(tukawanai, pre + ci)
                return mem[(i, a, b)]
        mem[(i, a, b)] = tukawanai
        return mem[(i, a, b)]

    res = MAX
    for a in range(1, 10 * N + 1):
        aa = a * Mb
        if aa % Ma != 0:
            continue
        b = aa // Ma
        if b >= 10 * N + 1:
            continue
        c = solve(N - 1, a, b)
        res = min(res, c)

    if res == MAX:
        res = -1
    print(res)


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

n = int(input())
ss = []
for i in range(n):
    ss.append(input())

def encode(s):
#     print(s)
    res = 0
    for ss in s:
        key = ord(ss)-ord('a')
        res += 10**key
    return res

lst = []
count = 0
for s in ss:
    en = encode(s)
#     print(en)
    for ls in lst:
        if ls == en:
            count += 1
#         print(s)
    lst.append(en)

print(count)
    


### FIXED CODE ###

# n = 5
# ss = ["abaaaaaaaa",
# "oneplustwo",
# "aaaaaaaaba",
# "twoplusone",
# "aaaabaaaaa"]

n = int(input())
ss = []
for i in range(n):
    ss.append(input())

newss = []
for s in ss:
    newss.append("".join(sorted(list(s))))
newss = sorted(newss)
newss.append("XXXXXXXXXX")

last = newss[0]
count = 1
res = 0
for i in range(1,n+1):
    if last == newss[i]:
        count +=1
#         print(newss[i])
    else:
        res += (count*(count-1))//2
#         print(newss[i], (count*(count-1))//2)
        count = 1
    last = newss[i]
print(res)
### BUGGY CODE ###

n = int(input())
Odd = []
OddCount = []
Even = []
EvenCount = []
list = input()

for i in range(n):
    if i%2==1:
        x = int(list.split(" ")[i])
        if x in Odd:
            OddCount[Odd.index(x)] += 1
        else:
            OddCount.append(1)
            Odd.append(x)
    else:
        x = int(list.split(" ")[i])
        if x in Even:
            EvenCount[Even.index(x)] += 1
        else:
            EvenCount.append(1)
            Even.append(x)

O1c = max(OddCount)
O1n = Odd[OddCount.index(O1c)]
Odd[OddCount.index(O1c)] = 0
OddCount[OddCount.index(O1c)] = 0

E1c = max(EvenCount)
E1n = Even[EvenCount.index(E1c)]
Even[EvenCount.index(E1c)] = 0
EvenCount[EvenCount.index(E1c)] = 0

if O1c > E1c:
    if O1n != E1n:
        print(n-O1c-E1c)
    else:
        print(n-O1c-max(EvenCount))
elif O1c < E1c:
    if O1n != E1n:
        print(n-O1c-E1c)
    else:
        print(n-max(OddCount)-E1c)
else:
    if O1n == E1n:
        if max(EvenCount) > max(OddCount):
            print(n-O1c-max(EvenCount))
        else:
            print(n-max(OddCount)-E1c)
    else:
        print(n-O1c-E1c)


### FIXED CODE ###

import collections

def answer(list,n):
    Even = collections.Counter(list[::2]).most_common(2)
    Odd = collections.Counter(list[1::2]).most_common(2)

    if Even[0][0] != Odd[0][0]:
        return n - Even[0][1] - Odd[0][1]
    else:
        if len(Even) == 1 or len(Odd) == 1:
            return n // 2
        else:
            return n - max(Even[0][1]+Odd[1][1],Even[1][1]+Odd[0][1])

N = int(input())
list = input().split(" ")
print(answer(list,N))
### BUGGY CODE ###

n, k, q = map(int, input().split())
S = []
A = []

for a in range(q) :
    A.append(int(input()))

for i in range(n) :
    S.append(int(k))
    if S[i] - len(A) + A.count(i+1) > 0 :
        print('Yes')
    else :
        print('No')

### FIXED CODE ###

n, k, q = map(int, input().split())
 
C = [0] * n
 
for a in range(q) :
    C[int(input())-1] += 1
 
sum_c = sum(C)
 
for i in range(n) :
    minus = sum_c - C[i]
    if minus < k :
        print('Yes')
    else :
        print('No')
### BUGGY CODE ###

a,b,n=map(int,input().split())
# s=n//b
nmax = (a*n)//b - a*(n//b)
# for i in range(1,s+1):
#     x = b*i-1
#     t = (a*x)//b - a*(x//b)
#     if t > nmax:
#         nmax = t
b_n = b
b_nn = 0
while b_n <= n:
    x = b_n -1
    t = (a*x)//b - a*b_nn
    if t > nmax:
        nmax = t
    b_n += b
    b_nn +=1
print(nmax)

### FIXED CODE ###

a,b,n=map(int,input().split())
s=n//b
nmax = (a*n)//b - a*(n//b)
# b_n = b
# b_nn = 0
# while b_n <= n:
#     x = b_n -1
#     t = (a*x)//b - a*b_nn
#     if t > nmax:
#         nmax = t
#     b_n += b
#     b_nn +=1
if s>0:
    x = b*s-1
    t = (a*x)//b - a*(s-1)
    if t > nmax:
        nmax = t
print(nmax)
### BUGGY CODE ###

n = int(input())
s = list(input())
m = [0] * n
ans = 0
for i in range(n - 1, -1, -1):
    for j in range(i):
        cnt = 0
        for k in range(n - i):
            if j + k == i:
                break
            if not s[i + k] == s[j + k]:
                break
            cnt += 1
        m[i] = max(m[i], cnt)
    ans = max(ans, m[i])
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())
b = 27
mod = 67280421310721
m = n // 2
x = [1] * (m + 1)
for i in range(1, m + 1):
    x[i] = (x[i - 1] * b) % mod
h0 = [0] * m
h0[0] = ord(s[0]) - 96
d = [{} for _ in range(m + 1)]
for i in range(1, m):
    h0[i] = (h0[i - 1] * b + (ord(s[i]) - 96)) % mod
for i in range(m, 0, -1):
    h = h0[i - 1]
    d[i][h] = 0
    for j in range(i, n):
        h *= b
        h %= mod
        h -= (x[i] * (ord(s[j - i]) - 96) % mod)
        h += (ord(s[j]) - 96)
        h %= mod
        if h in d[i]:
            if (j - i + 1 - d[i][h]) >= i:
                print(i)
                exit()
        else:
            d[i][h] = j - i + 1
print(0)
### BUGGY CODE ###

import numpy as np
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())),dtype=np.int64)
B=np.zeros(N+1,dtype=np.int64)
if K>41:
  A=np.ones(N,dtype=np.int64)*N
else:
  for k in range(K):
    for i in range(N):
      B[max(0,i-int(A[i]))] +=1
      B[min(N,i+int(A[i])+1)] -=1
    A=np.cumsum(B)[:N]
    B=np.zeros(N+1,dtype=np.int64)

for i in A:
  print(i)

### FIXED CODE ###

import numpy as np
from numba import jit
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())),dtype=np.int64)
@jit
def loop(a,k):
  if k>41:
    ans=np.ones(N,dtype=np.int64)*N
  else:
    ans=a
    for j in range(k):
      B=np.zeros(N+1,dtype=np.int64)
      for i in range(N):
        B[max(0,i-int(ans[i]))] +=1
        B[min(N,i+int(ans[i])+1)] -=1
      ans=np.cumsum(B)[:N]
  return ans

for i in loop(A,K):
  print(i)
### BUGGY CODE ###

s = input()
q = int(input())
head = 0

for i in range(q):
    L = list(input().split())
    if L[0] == '1' :
        head = (head + 1)%2
    if L[0] == '2' :
        if head == 0:
            if L[1] == '1' :
                s = L[2] + s
            if L[1] == '2' :
                s = s + L[2]
        if head == 1:
            if L[1] == '1' :
                s = s + L[2]
            if L[1] == '2' :
                s = L[2] + s
if head == 0:
    print(s)
else: 
    s = ''.join(reversed(s))
    print(s)
        

### FIXED CODE ###


from collections import deque

s = deque(list(input()))
q = int(input())
head = 0

for i in range(q):
    L = list(input().split())
    if L[0] == '1' :
        head = (head + 1)%2
    if L[0] == '2' :
        if head == 0:
            if L[1] == '1' :
                s.appendleft(L[2])
            if L[1] == '2' :
                s.append(L[2])
        if head == 1:
            if L[1] == '1' :
                s.append(L[2])
            if L[1] == '2' :
                s.appendleft(L[2])
if head == 0:
    print(''.join(s))
else: 
    print(''.join(reversed(s)))
### BUGGY CODE ###

N = int(input())

mult = 1
A = list(map(int, input().split()))
if 0 in A:
    print(0)
else:
    try:
        for a in A:
            mult *= a
            
        if mult > 10**18:
            print("-1")
        else:
            print(mult)
    except:
        print("-1")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
maxi = 10**18
def main():
    if 0 in A:
        print(0)
        return
    mult = 1
    for a in A:
        mult *= a
        if mult > maxi:
            print(-1)
            return 
    print(mult)

main()
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
for i in range(1,n):
    print(str(A.index(i)+1)+" ",end="")
print(str(A.index(n)+1),end="")
    

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
ans=[None for i in range(n)]
for i in range(n):
    ans[A[i]-1]=str(i+1)
print(" ".join(ans))
### BUGGY CODE ###

import sys


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        imos = [0] * (N + 1)
        for j in range(N):
            # s = A[j]
            l, r = max(0, j - A[j]), min(j + A[j], N - 1)
            # print("l,r,s = {} {} {}".format(l, r, s))
            imos[l] += 1
            imos[r + 1] -= 1
        for k in range(N):
            imos[k + 1] = imos[k] + imos[k + 1]
        A = imos[:N]
        if A.count(N) == N:
            print(*A)
            sys.exit()

    print(*imos[:N])


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        imos = [0] * (N + 1)
        for j in range(N):
            # s = A[j]
            l, r = max(0, j - A[j]), min(j + A[j], N - 1)
            # print("l,r,s = {} {} {}".format(l, r, s))
            imos[l] += 1
            imos[r + 1] -= 1
        for k in range(N):
            imos[k + 1] = imos[k] + imos[k + 1]
        A = imos[:N]
        if A.count(N) == N:
            print(*A)
            sys.exit()

    print(*imos[:N])


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

#!/usr/bin/env python3

import math

n,m = list(map(int,input().split(" ")))

A = list(map(int,input().split(" ")))
A.sort()
#print(A)
B = []
C = []

for i in range(m):
    b,c = list(map(int,input().split(" ")))
    for j in range(b):
        if A[j] < c:
            A[j] = c
        else:
            break
    A.sort()
    #print(A)
print(sum(A))

### FIXED CODE ###

#!/usr/bin/env python3

import math

n,m = list(map(int,input().split(" ")))

A = list(map(int,input().split(" ")))
#print(A)
s = []
t = []
u = []
for i in range(m):
    b,c = list(map(int,input().split(" ")))
    t.append((c,b))
t.sort()
#print(t)
#print(t[-1][0])
for i in range(n):
    if A[i] < t[-1][0]:
        u.append(A[i])
    else:
        s.append(A[i])
#print(u)
#print(s)
u.sort()
#print(u)
x = 0
y = 0
ans = 0
count = 0
for i in range(len(u)):
    #print(x,y)
    if u[i] < t[-x-1][0]:
        u[i] = t[-x-1][0]
    if i == y + t[-x-1][1] - 1:
        x += 1
        y += i+1 - y
        if x == len(t):
            break
#print(u)
ans += sum(s)
ans += sum(u)
print(ans)
### BUGGY CODE ###

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]
marks = []

prev = -1
for i in range(K-1, N):
    prod = 1
    # print('prod')
    for k in range(K):
        prod *= A[i-k]
        # print(A[i-k])
    if prev != -1:
        if prev < prod:
            print('Yes')
        else:
            print('No')
    prev = prod

### FIXED CODE ###

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]
marks = []

for i in range(K, N):
    prev = A[i-K]
    next_ = A[i]
    if prev < next_:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

changes = []
for leader in range(N):
    change = 0
    for j in range(N):
        if j < leader and S[j] == 'W':
            change += 1
        if leader < j and S[j] == 'E':
            change += 1
    changes.append(change)

print(min(changes))

### FIXED CODE ###

import bisect

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

changes = []

wests = [i for i in range(N) if S[i] == 'W']
# print(wests)
easts = [i for i in range(N) if S[i] == 'E']
# print(easts)

for leader in range(N):
    change = 0
    change += bisect.bisect_left(wests, leader)
    change += len(easts) - bisect.bisect_right(easts, leader)
    changes.append(change)

print(min(changes))