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

N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 0
for i in list(set(ca)):
    if i == 0:
        count += sum([1 if j == 0 else 0 for j in ca])
    number = sum([1 if j == i else 0 for j in ca])
    count += int(number * (number-1) /2)

print(count)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

def Zalgo(S):
    N = len(S)
    A = [0]*N

    froms = -1
    lasts = -1
    for i in range(1, N):
        same = 0
        if froms != -1:
            same = min(A[i-froms], lasts-i)
            same = max(0, same)
        while i+same<N and S[same] == S[i+same]:
            same += 1
        
        if i+same > lasts:
            lasts = i+same
            froms = i
        A[i] = same
    A[0] = N
    return A

N = int(input())
S = input().rstrip()

ans = 0
for i in range(N):
    A = Zalgo(S[i:])
    res = 0
    L = len(A)
    for j,a in enumerate(A):
        res = max(res, min(j, a))
    ans = max(res, ans)
print(ans)


### FIXED CODE ###


N = int(input())
S = input()
ans = 0

for L in range(1,N): #比較する文字列同士の距離
    dp = [0] * (N+5)
    for x in range(N-L): #文字列の始点を全探索
        if S[x] == S[x+L]:
            if x == 0:
                dp[x] += 1
            else:
                dp[x] = min(dp[x-1]+1,L)
            ans = max(ans,dp[x])
        else:
            dp[x] = 0
            
print(ans)
### BUGGY CODE ###

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

for i in range(1, N+1):
    min_p_index = p_num.index(i)+1
    print(min_p_index)

### FIXED CODE ###

N = int(input())
p_num = list(map(int, input().split()))
ans_list = [0] * N

for i in range(N):
    ans_list[p_num[i] - 1] = i+1

for i in range(N):
    print(ans_list[i])
### BUGGY CODE ###

cnt = 0

def merge(array, left, middle, right):
    n1 = middle - left
    n2 = right - middle
    L = []
    R = []
    for i in range(n1):
        L.append(array[left + i])
    for i in range(n2):
        R.append(array[middle + i])
    L.append(float("inf"))
    R.append(float("inf"))
    i = 0
    j = 0
    for k in range(left, right):
        global cnt
        cnt += 1
        if L[i] <= R[j]:
            array[k] = L[i]
            i += 1
        else:
            array[k] = R[j]
            j += 1


def mergeSort(array, left, right):
    if left + 1 < right:
        middle = int((left + right) / 2.)
        mergeSort(array, left, middle)
        mergeSort(array, middle, right)
        merge(array, left, middle, right)


n = int(input())
array = [int(x) for x in input().split()]
mergeSort(array, 0, len(array))
print(*array)
print(cnt)


### FIXED CODE ###

cnt = 0

def merge(array, left, middle, right):
    n1 = middle - left
    n2 = right - middle
    L = array[left:left + n1] + [float("inf")]
    R = array[middle:middle + n2] + [float("inf")]
    i = 0
    j = 0
    for k in range(left, right):
        global cnt
        cnt += 1
        if L[i] <= R[j]:
            array[k] = L[i]
            i += 1
        else:
            array[k] = R[j]
            j += 1


def mergeSort(array, left, right):
    if left + 1 < right:
        middle = int((left + right) / 2.)
        mergeSort(array, left, middle)
        mergeSort(array, middle, right)
        merge(array, left, middle, right)


n = int(input())
array = [int(x) for x in input().split()]
mergeSort(array, 0, len(array))
print(*array)
print(cnt)
### BUGGY CODE ###

import itertools

N = int(input())
#print(N)
L = [int(i) for i in input().split()]
#print(L)
C = itertools.combinations(L, 3)

cnt = 0
for j in C:
    a, b, c = j
    if a < b+c and b < c+a and c < a+b:
        cnt += 1

print(cnt)

### FIXED CODE ###

from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
#print(L)
ans = 0
for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        ans += bisect_left(L, a + L[j])  - j - 1
        #print(ans, end=",")
print(ans)
### BUGGY CODE ###

class FastModuloTransform():
    def __init__(self, omega, n, mod):
        self.n = n
        self.omega = omega
        self.mod = mod
        self.rev = pow(omega, mod - 2, mod)

    def _bit_reverse_(self, d):
        n = len(d)
        ns = n >> 1
        nss = ns >> 1
        ns1 = ns + 1
        i = 0
        for j in range(0, ns, 2):
            if j < i:
                d[i], d[j] = d[j], d[i]
                d[i + ns1], d[j + ns1] = d[j + ns1], d[i + ns1]
            d[i + 1], d[j + ns] = d[j + ns], d[i + 1]
            k = nss
            i ^= k
            while k > i:
                k >>= 1
                i ^= k
        return d

    def _fmt_(self, A, base):
        halfpow = pow(base, self.n // 2, self.mod)
        n = self.n
        m = 1
        while n > 1:
            n >>= 1
            w = pow(base, n, self.mod)
            wk = 1
            for j in range(m):
                for i in range(j, self.n, 2 * m):
                    U = A[i]
                    V = (A[i + m] * wk) % self.mod
                    A[i] = (U + V) % self.mod
                    A[i + m] = (U + V * halfpow) % self.mod
                wk = (wk * w) % self.mod
            m <<= 1
        return A

    def fmt(self, f):
        A = f + [0] * (self.n - len(f))
        self._bit_reverse_(A)
        F = self._fmt_(A, self.omega)
        return F

    def ifmt(self, F):
        A = F + [0] * (self.n - len(F))
        self._bit_reverse_(A)
        nrev = pow(self.n, self.mod - 2, self.mod)
        f = [(e * nrev) % self.mod for e in self._fmt_(A, self.rev)]
        return f

    def convolute(self, f, g):
        F = self.fmt(f)
        G = self.fmt(g)
        H = [(s * t) % self.mod for s, t in zip(F, G)]
        h = self.ifmt(H)
        return h

fmt = FastModuloTransform(299814, 2**13, 998244353)

MOD = 998244353

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

F = [0]
res = 0

for i in range(N):
    F[0] += 1
    f = [0 for _ in range(A[i] + 1)]
    f[0] = 1
    f[-1] = 1
    F = fmt.convolute(F, f)
    F = F[:S + 1]
    res += F[S]
    res %= MOD

print(res)

### FIXED CODE ###

MOD = 998244353

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

F = [0 for _ in range(S + 1)]
res = 0

for i in range(N):
    F[0] += 1
    for j in range(S + 1)[::-1]:
        if j - A[i] >= 0:
            F[j] += F[j - A[i]]
    res += F[S]
    res %= MOD

print(res)
### BUGGY CODE ###

N, K = map(int, input().split())
ans = 0
for i in range(1,N+1):
    if 2*i % K != 0:
        continue
    for j in range(1, N+1):
        if 2*j % K != 0:
            continue
        if (i+j)% K != 0:
            continue
        for k in range(1, N+1):
            if 2*k % K != 0:
                continue
            if (i+k) % K != 0:
                continue
            if (j+k) % K != 0:
                continue
            ans += 1
print(ans)
                

### FIXED CODE ###

N, K = map(int, input().split())
if K % 2 == 1:
    a = N // K
    print(a**3)
else:
    a = N//K
    a2 = N//(K//2) -a
    print(a**3 +a2**3)
### BUGGY CODE ###

while True:
    n=input()
    if n==0:
        break
    dp=[[0 for i in range(n)]for j in range(n)]
    flag0=0
    for i in range(n):
        j=0
        for c in raw_input():
            if c == ".":
                dp[i][j]=1
                flag0=1
            j+=1
    if flag0==0:
        print 0
    else:
        solve=1
        while True:
            flag=0
            for y in xrange(n-solve):
                for x in xrange(n-solve):
                    if dp[y][x]==solve and dp[y+1][x]==solve and\
                       dp[y][x+1]==solve and dp[y+1][x+1]==solve:
                        dp[y][x]=solve+1
                        flag=1
            if flag==0:
                break
            solve+=1
        print solve

### FIXED CODE ###

while True:
    n=input()
    if n==0:
        break
    dp=[[0 for i in range(n+1)]for j in range(n+1)]
    for i in range(1,n+1):
        j=0
        line=" "+raw_input()
        for c in line:
            if c == ".":
                dp[i][j]=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1
            j+=1
    allmax=0
    for i in range(n+1):
        if allmax<max(dp[i]):
            allmax=max(dp[i])
    print allmax
### BUGGY CODE ###

import sys
sys.setrecursionlimit(300000)
from collections import defaultdict

N, Q = map(int, input().split())
adjacent = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    adjacent[a].append(b)
    adjacent[b].append(a)
scores = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    scores[p] += x

ans = [0] * N


def dfs(to, fr, score):
    score += scores[to]
    ans[to] = score
    for u in adjacent[to]:
        if u == fr:
            continue
        dfs(u, to, score)


dfs(0, -1, 0)
print(' '.join([str(ans[i]) for i in range(N)]))


### FIXED CODE ###

from collections import defaultdict, deque

N, Q = map(int, input().split())
adjacent = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    adjacent[a].append(b)
    adjacent[b].append(a)
ans = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x

q = deque([(0, -1)])
while len(q) > 0:
    u, p = q.pop()
    for v in adjacent[u]:
        if v == p:
            continue
        ans[v] += ans[u]
        q.appendleft((v, u))
print(' '.join([str(ans[i]) for i in range(N)]))
### BUGGY CODE ###

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

ans = []*N
for i in range(1,N):
    print(A.count(i))
print(0)

### FIXED CODE ###

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

ans = [0]*N
for i in A:
    ans[i-1] += 1

for i in range(N):
    print(ans[i])
### BUGGY CODE ###

import collections

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

ans = 0
q = collections.deque()
for i in range(n):
    tmp = (1+a[i])/2
    q.append(tmp)
    if len(q) > k:
        q.popleft()
    ans = max(ans,sum(q))
print(ans)




### FIXED CODE ###

import collections

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

ans = 0
tmp = 0
q = collections.deque()
for i in range(n):
    e = (1+a[i])/2
    q.append(e)
    tmp += e
    if len(q) > k:
        tmp -= q.popleft()
    ans = max(ans,tmp)
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
a = 0
max_flag = False
for l in range(N):
    a = A[l]
    x = A[l]
    for j in range(l+1,N):
        a += A[j]
        x = x ^ A[j]
        if a == x:
            ans += 1
        else:
            break
print(ans + N)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
num = 0
a = 0
x = 0
k = 0
for l in range(N):
    for j in range(k,N):
        a += A[j]
        x =  x ^ A[j]
        if a  != x:
            ans += j - l
            k = j
            x = x ^ A[l] ^ A[j]
            a = a - A[l] - A[j]
            break
        elif j == N-1:
            ans += N-l
            k = j
            x = x ^ A[l] ^ A[j]
            a = a - A[l] - A[j]
print(ans )
### BUGGY CODE ###

def solve(n, k):
    MOD = 998244353

    if n > k:
        return 0

    invs = [1] * (k + 1)
    pf, kf = 1, 1
    for m in range(2, k + 1):
        pf = kf
        kf *= m
        kf %= MOD
        invs[m] = pow(kf, MOD - 2, MOD)

    ans = 0
    if k & 1 == 0:
        if n == 1:
            ans = 1
        else:
            r = k >> 1
            t = r - n + 1
            ans = pf * (invs[r] * invs[r - 1] - invs[r + t] * invs[k - r - t - 1]) % MOD

    for r in range(k // 2 + 1, k + 1):
        if r * 2 >= n + k:
            ans += kf * invs[r] * invs[k - r]
        else:
            t = r - n + 1
            ans += kf * (invs[r] * invs[k - r] - invs[r + t] * invs[k - r - t])
        ans %= MOD
    return ans


print(solve(*map(int, input().split())))


### FIXED CODE ###

def solve(n, k):
    MOD = 998244353

    if n > k:
        return 0
    if n == 1:
        return pow(2, k - 1, MOD)

    invs = [1] * (k + 1)
    pf, kf = 1, 1
    for m in range(2, k + 1):
        pf = kf
        kf *= m
        kf %= MOD
        invs[m] = pow(kf, MOD - 2, MOD)

    ans = 0
    if k & 1 == 0:
        r = k >> 1
        s = k - n + 1
        ans = pf * (invs[r] * invs[r - 1] - invs[s] * invs[k - s - 1]) % MOD

    for r in range(k // 2 + 1, k + 1):
        if r * 2 >= n + k:
            ans += kf * invs[r] * invs[k - r]
        else:
            s = r * 2 - n + 1
            ans += kf * (invs[r] * invs[k - r] - invs[s] * invs[k - s])
        ans %= MOD
    return ans


print(solve(*map(int, input().split())))
### BUGGY CODE ###

n, m, q = map(int,input().split())
bord = [[0 for _j in range(n+2)] for _i in range(n+2)]

for _i in range(m):
    left, right = map(int, input().split())
    bord[left][right] += 1

for i in range(1, n+2):
    for j in range(1, n+2):
        bord[i][j] += bord[i][j-1]

result = []
for _i in range(q):
    p, q = map(int, input().split())
    c = 0
    for i in range(p, q+1):
        c += bord[i][q]-bord[i][p-1]
    result.append(c)
print(*result)

### FIXED CODE ###

n, m, q = map(int,input().split())
bord = [[0 for _j in range(n+2)] for _i in range(n+2)]

for _i in range(m):
    left, right = map(int, input().split())
    bord[left][right] += 1

for i in range(1, n+2):
    for j in range(1, n+2):
        bord[i][j] += bord[i][j-1]

result = []
for _i in range(q):
    p, q = map(int, input().split())
    c = 0
    for i in range(p, q+1):
        c += bord[i][q]-bord[i][p-1]
    result.append(c)
print(*result)
### BUGGY CODE ###

t = int(input())
for i in range(t):
    a, b, c, d = map(int, input().split())
    rec = [a]
    flag = False
    num = 0
    while True and num < 100000:
        if a < b:
            break
        else:
            a = a % b
        if a <= c:
            a += d
        else:
            break
        if a in rec:
            flag = True
            break
        num += 1
        rec.append(a)
    if flag:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

T = int(input())


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


for i in range(T):
    a, b, c, d = map(int, input().split())
    if a < b:
        print('No')
    elif d < b:
        print('No')
    elif c >= b:
        print('Yes')
    else:
        g = gcd(b, d)
        if b - g + a % g > c:
            print('No')
        else:
            print('Yes')
### BUGGY CODE ###

# ABC 162

# https://note.nkmk.me/python-gcd-lcm/
A = int(input())
# 最小公倍数
ans = 0
from fractions import gcd
from functools import reduce

def Ngcd(*numbers):
    return reduce(gcd, numbers)
d = dict()

for i in range(1,A+1):
    for j in range(1,A+1):
        for k in range(1,A+1):
            tmp = ','.join(list(map(str,sorted([i,j,k]))))
            if tmp in d.keys():
                ans +=d[tmp]
            else:
                min_bai = Ngcd(i,j,k)
                d[tmp] = min_bai
                ans += min_bai
print(ans)

### FIXED CODE ###

A = int(input())
# 最小公倍数
ans = 0
from math import gcd


for i in range(1,A+1):
    for j in range(1,A+1):
        for k in range(1,A+1):
            ans += gcd(gcd(i,j),k)
print(ans)
### BUGGY CODE ###

N, M = list(map(int,input().split()))
 
d = int(M/N)
 
if M%N == 0:
	print(d)
else: 
	for i in range(d):
		if M%(d-i) == 0:
			print(d-i)
			break
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

### FIXED CODE ###

import math, sys, random

N, M = list(map(int,input().split()))
# N, M = 1111, 1000000000

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

d = int(math.floor(M/N))

if M%N == 0:
	print(d)
	sys.exit()

i = 0
f = False
while True:
	if M%(N+i+1) == 0:
		print(int(M/(N+i+1)))
		sys.exit()
	i += 1
	if i == 100000 and is_prime(M):
		print(1)
		sys.exit()
### BUGGY CODE ###

import heapq

n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

tree = [[] for i in range(n)]
for i in range(m):
    a, b = info[i]
    a -= 1
    b -= 1
    tree[a].append(b)

set_ = set([])
for i in range(n):
    for j in tree[i]:
        set_.add(j)

start = set([])
for i in range(n):
    if i not in set_:
        start.add(i)

q = []
for i in start:
    heapq.heappush(q, (0, i))
dp = [0]*n
while q:
    cnt, pos = heapq.heappop(q)
    cnt = -cnt
    for next_pos in tree[pos]:
        if cnt + 1 > dp[next_pos]:
            dp[next_pos] = cnt + 1
            heapq.heappush(q, (-(cnt + 1), next_pos))
print(max(dp))

### FIXED CODE ###

import sys


input = sys.stdin.readline
sys.setrecursionlimit(200000)

n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
tree = [[] for i in range(n)]
start_point = [True] * n
for i in range(m):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    start_point[info[i][1] - 1] = False
     
dp = [-1]*n

def dfs(pos):
    if dp[pos] !=-1:
        return dp[pos]
    if not tree[pos]:
        dp[pos] = 0
        return 0
    ans = 0
    for i in tree[pos]:
        ans = max(ans, dfs(i) + 1)
    dp[pos] = ans
    return ans

for i in range(n):
    dfs(i)
print(max(dp))
### BUGGY CODE ###

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

counter=0
flag=True

for i in range(N):
    for j in range(i+1):

        if x[i]>x[j] and flag:
            counter+=1
            flag=False


    flag=True
print(N-counter)


### FIXED CODE ###

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

counter=0
flag=True
#最小値
a=x[0]
for i in range(N):

    if a>x[i] :
        a=x[i]
    if a<x[i]:
        counter+=1

print(N-counter)
### BUGGY CODE ###

s=input()
can=0
mayor=0
for i in range(len(s)):
  can=0
  can3=0
  can2=0
  if s[i]=="A":
    posicion=i
    a=len(s[posicion:])
    for i in range(len(s)-posicion):
      posicion2=i+posicion
      #print(s[i])
      if s[i+posicion]=="Z":
        if posicion2==a:
          can+=1
          break
        else:
          for i in range(len(s)-posicion2):   
            #if s[i+posicion2]=="Z":          
             # can+=1
            #else:
            if s[i+posicion2]!="Z":
              can2+=1
              #print("sdasd")
              #print(i+posicion,len(s)-posicion2)
              if i+posicion2==len(s)-1:
                can2=0
            else:
              can3+=1
          can3=can3+can2
        break 
      #elif s[i+posicion]=="Z":
        #can+=1
        #break
      elif i+posicion==len(s)-1 and s[i+posicion]!="Z":
        can=0
      else:
        can+=1
  can=can+can3
  if can>mayor:
    mayor=can
print(mayor)
'''
a=len(s[posicion:])

for i in range(len(s)-posicion):
  posicion2=i+posicion
  #print(s[i])
  if s[i+posicion]=="Z":
    if posicion2==a:
      can+=1
      break
    else:
      for i in range(len(s)-posicion2):   
        if s[i+posicion2]=="Z":          
          can+=1
        else:
          break
    break 
  #elif s[i+posicion]=="Z":
    #can+=1
    #break
  elif i+posicion==len(s)-1 and s[i+posicion]!="Z":
    can=0
  else:
    can+=1
print(can)
'''

### FIXED CODE ###

s = input()

indexA = 0
indexZ = len(s)

for i in range(indexZ):
	if s[i] == "A":
		indexA = i
		break

s = s[::-1]

for i in range(len(s)):
	if s[i] == "Z":
		indexZ = len(s)-i
		break

print(indexZ - indexA)
### BUGGY CODE ###

import math
import sys

n, m = map(int, input().split())
a_list = [-1]
for _ in range(m):
    a_list.append(int(input()))
a_list.append(n + 1)

ans = 1
for i in range(1, len(a_list)):
    sub = a_list[i] - a_list[i-1] - 1
    if i > 1 and sub == 0:
        print(0)
        sys.exit()
    if sub <= 2:
        continue
    sub -= 1
    count = 0
    for j in range(sub // 2 + 1):
        count += math.factorial(sub - j) // math.factorial(j) // math.factorial(sub - j * 2)
    ans *= count
print(ans % 1000000007)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
readline = sys.stdin.readline

N, M = map(int, readline().split())
ans = [0] * (N + 2)
ans[0] = 1
for _ in range(M):
    a = int(readline())
    ans[a] = -1

for i in range(1, N + 1):
    if ans[i] == -1:
        continue
    a1 = max(ans[i - 2], 0)
    a2 = max(ans[i - 1], 0)
    ans[i] = a1 + a2

print(ans[N] % (10 ** 9 + 7))
### BUGGY CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
input = sys.stdin.readline
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            for j in range(len(se[kkk])):
                if se[kkk][j] <= i-n:
                    return True
            else:
                se[kkk].append(i)
        else:
            bs.insort(data,kkk)
            se[kkk] = [i]
    return False
def solver():
    n = onem()

    s = list(input())
    l = 0
    r = n//2
    for i in range(n):
        mid = -(-(l+r)//2)
        ans = search(s,mid)
        if l == mid:
            break
        if ans:
            l = mid
        else:
            r = mid-1
    print(l)



if __name__ == '__main__':
    solver()





### FIXED CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            if se[kkk] <= i-n:
                    return True
        else:
            bs.insort(data,kkk)
            se[kkk] = i
    return False
def solver():
    n = onem()

    s = list(input())
    l = 0
    r = n//2
    for i in range(n):
        mid = -(-(l+r)//2)
        ans = search(s,mid)
        if l == mid:
            break
        if ans:
            l = mid
        else:
            r = mid-1
    print(l)



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

import numpy as np
n = int(input())
l = np.array(sorted(list((map(int, input().split())))))
m = len(l)
cnt = 0
for i in range(m - 1):
    for j in range(i + 1, m):
        cnt += np.sum(l[j + 1:] < (l[i] + l[j]))
print(cnt)

### FIXED CODE ###

import bisect

n = int(input())
l = sorted(list((map(int, input().split()))))

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += max(0, bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(cnt)