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

import numpy as np

in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)
res = 0
for i in range(N-2):
    str_list = ['R', 'G', 'B']
    str_list.remove(S[i])
    # print("i_str",str_list)
    for j in range(1+i,N-1):
        if S[i] != S[j]:
            a = list(np.copy(str_list))
            a.remove(S[j])
            # print("j_str",a)
            b = (a[0] == np.array(list(S[j+1:])))
            cou_b = sum(b)
            ind_list = b.argsort()[::-1][:cou_b] + j+1

            res += len(ind_list[ind_list-j != j-i])

print(res)



### FIXED CODE ###

import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

res = 0
for i in range(N-2):
    n = 1
    while True:
        j = i+n
        k = j+n
        if k > N-1: break
        res += (S[i] != S[j] and S[j] != S[k] and S[k] != S[i])
        n += 1
    
    
rgb = S.count("R") * S.count("G") * S.count("B")
print(rgb - res)
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
s = a[:1]
t = a[1:]
x = sum(s)
y = sum(t)
if x-y==0:
  ans = 0
else:
  ans = abs(x-y)

for i in range(2,N):
  s = a[:i]
  t = a[i:]
  x = sum(s)
  y = sum(t)
  if x-y==0:
    ans = 0
    break
  elif abs(x-y)<ans:
    ans = abs(x-y)
print(ans)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
s = a[:1]
t = a[1:]
x = sum(s)
y = sum(t)
if x==y:
  ans = 0
else:
  ans = abs(x-y)

for i in range(1,N-1):
  x += a[i]
  y -= a[i]
  if x==y:
    ans = 0
    break
  elif abs(x-y)<ans:
    ans = abs(x-y)
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()

ans = 0
for a in range(0,n-2):
    for b in range(a,n-1):
        e = b-a
        if s[a]!=s[b]:
            for c in range(b,n):
                f = c-b
                if e!=f:
                    if s[a]!=s[c] and s[b]!=s[c]:
                        ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

for i in range(n):
    for j in range(1,n//2+1):
        if i+2*j>=n:
            break
        
        if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:
            ans -= 1
print(ans)
### BUGGY CODE ###

from collections import deque
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(list(input()))
q = deque()
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append((i, j, 0))
dxdy = [(-1, 0), (0, -1), (0, 1), (1, 0)]
ans = 0
while q:
    y, x, cnt = q.popleft()
    for dx, dy in dxdy:
        if not(0<=x+dx<w and 0<=y+dy<h):
            continue
        if a[y+dy][x+dx]=='.':
            a[y+dy][x+dx] = '#'
            q.append((y+dy, x+dx, cnt+1))
            ans = cnt+1
print(ans)

### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(list(input()))
q = deque()
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append((i, j, 0))
dxdy = [(-1, 0), (0, -1), (0, 1), (1, 0)]
ans = 0
while q:
    y, x, cnt = q.popleft()
    for dx, dy in dxdy:
        if not(0<=x+dx<w and 0<=y+dy<h):
            continue
        if a[y+dy][x+dx]=='.':
            a[y+dy][x+dx] = '#'
            q.append((y+dy, x+dx, cnt+1))
            ans = cnt+1
print(ans)
### BUGGY CODE ###

import math
N = int(input())
sum1 = 0
for a in range(1,N+1):
    for b in range(1,N+1):
        for c in range(1,N+1):
            sum1 += math.gcd(c,math.gcd(a,b))
print(sum1)

### FIXED CODE ###

import math
N = int(input())
sum1 = 0
for a in range(1,N+1):
    for b in range(1,N+1):
        for c in range(1,N+1):
            sum1 += math.gcd(c,math.gcd(a,b))
print(sum1)
### BUGGY CODE ###

def main():
    h,w = map(int,input().split())
    a=[]
    que=[]
    for _ in range(h):
        a.append(list(input()))
    for i in range(h):
        for j in range(w):
            if a[i][j]=="#":
                que.append([i,j])
                a[i][j]=0
    ans=0
    while que!=[]:
        [i,j]=que[0]
        que.pop(0)
        if j<w-1 and a[i][j+1]==".":
            que.append([i,j+1])
            a[i][j+1]=a[i][j]+1
            if ans < a[i][j]+1:
                ans=a[i][j]+1
        if 0<j and a[i][j-1]==".":
            que.append([i,j-1])
            a[i][j-1]=a[i][j]+1
            if ans < a[i][j]+1:
                ans=a[i][j]+1
        if i<h-1 and a[i+1][j]==".":
            que.append([i+1,j])
            a[i+1][j]=a[i][j]+1
            if ans < a[i][j]+1:
                ans=a[i][j]+1
        if 0<i and a[i-1][j]==".":
            que.append([i-1,j])
            a[i-1][j]=a[i][j]+1
            if ans < a[i][j]+1:
                ans=a[i][j]+1
    print(ans)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    h,w = map(int,input().split())
    a=[]
    que=[]
    for _ in range(h):
        a.append(list(input()))
    for i in range(h):
        for j in range(w):
            if a[i][j]=="#":
                que.append([i,j])
                a[i][j]=0
    ans=0
    while que!=[]:
        tank=[]
        for i,j in que:
            if j<w-1 and a[i][j+1]==".":
                tank.append([i,j+1])
                a[i][j+1]=a[i][j]+1
            if 0<j and a[i][j-1]==".":
                tank.append([i,j-1])
                a[i][j-1]=a[i][j]+1
            if i<h-1 and a[i+1][j]==".":
                tank.append([i+1,j])
                a[i+1][j]=a[i][j]+1
            if 0<i and a[i-1][j]==".":
                tank.append([i-1,j])
                a[i-1][j]=a[i][j]+1
        que=tank
        ans+=1
    print(ans-1)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

e = [0] * 1001
e[1] = 1.0
for i in range(2, 1001):
    e[i] = e[i-1] + 0.5

ans = 0
for i in range(n-k+1):
    tmp = 0
    for j in range(k):
        tmp += e[p[i+j]]
    ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

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

e = [0] * 1001
e[1] = 1.0
for i in range(2, 1001):
    e[i] = e[i-1] + 0.5

ans = [0] * (n-k+1)
for i in range(k):
    ans[0] += e[p[i]]
for i, v in enumerate(range(k, n), start=1):
    ans[i] = ans[i-1] + e[p[v]] - e[p[v-k]]
print(max(ans))
### BUGGY CODE ###

import math
import fractions
import collections
import itertools
from collections import deque
d=collections.deque()
S=list(input())
N=len(S)
cnt=0

amari=[0]*(N+1)
num=0
for i in range(N):
    d.append(int(S[i]))
#print(d)
for i in range(N):
    n=d.pop()
    num=(num+pow(10,i)*n)%2019
    amari[i+1]=num
#print(amari)
#c=collections.Counter(amari)
#values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
amari.sort()
#for i in range(len(key)):
#    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#xprint(l)
buf=0
#print(amari)
for i in range(N-1):
    if amari[i]==amari[i+1]:
        buf=buf+1
    else:
        cnt=cnt+((buf+1)*buf)//2
        buf=0
    #print(buf)
cnt=cnt+(buf*(buf+1))//2
print(cnt)

### FIXED CODE ###

import math
import fractions
import collections
import itertools
from collections import deque
d=collections.deque()
S=list(input())
N=len(S)
cnt=0

amari=[0]*(N+1)
num=0
for i in range(N):
    d.append(int(S[i]))
#print(d)
for i in range(N):
    n=d.pop()
    num=(num+pow(10,i,2019)*n)%2019
    amari[i+1]=num
#print(amari)
#c=collections.Counter(amari)
#values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
amari.sort()
#for i in range(len(key)):
#    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#xprint(l)
buf=0
#print(amari)
c=collections.Counter(amari)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
#for i in range(len(key)):
#    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#xprint(l)
for i in range(len(values)):
    cnt=cnt+(values[i]*(values[i]-1))//2
print(cnt)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split(' ')))
const = 1000000007
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += A[i] * A[j]
print(ans%const)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split(' ')))
const = 1000000007
ans = 0
total = sum(A)
for i in range(N):
    total -= A[i]
    ans += A[i] * total
print(ans%const)
### BUGGY CODE ###

MAX = 10 ** 18

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

ans = 1
for i in range(n):
  if ans == 0: break
  ans *= a[i]

if ans > MAX:
  print(-1)
else:
  print(ans)


### FIXED CODE ###

MAX = 10 ** 18

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

if a[-1] == 0:
  print(0)
else:
  ans = 1
  for i in range(n):
    if ans > MAX: break
    ans *= a[i]

  if ans > MAX:
    print(-1)
  else:
    print(ans)
### BUGGY CODE ###

import numpy as np
from numba import njit

@njit(cache=True)
def main(N, s, dpt):
    result = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
            if dpt[i][j] > result:
                result = dpt[i][j]

    return result

if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()], dtype='int32')

    dpt = np.array([[0] * (N + 1) for i in range(N + 1)])

    print(main(N, s, dpt))


### FIXED CODE ###

import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))
### BUGGY CODE ###

from bisect import bisect_right,bisect_left
import sys
input = sys.stdin.readline

n,k=map(int,input().split())
a=list(map(int,input().split()))
ap,an=[],[]
zeronum=0
for i in range(n):
  if a[i]>0:
    ap.append(a[i])
  elif a[i]<0:
    an.append(-a[i])
  else:
    zeronum+=1
an.sort()
ap.sort()
np,nn=len(ap),len(an)
if np*nn<k<=np*nn+zeronum*(zeronum-1)//2+zeronum*(np+nn):
  print(0)
else:
  #print(ap)
  #print(an)
  if k<=np*nn:
    ng=10**18
    ok=0
    while ng-ok>1:
      mid=(ok+ng)//2
      cnt=0
      for i in range(nn):
        if mid%an[i]!=0:
          cnt+=np-bisect_left(ap,mid//an[i]+1)
        else:
          cnt+=np-bisect_left(ap,mid//an[i])
      #print(cnt)
      if cnt>=k:
        ok=mid
      else:
        ng=mid
    print(-ok)
  else:
    k-=np*nn+zeronum*(zeronum-1)//2+zeronum*(np+nn)
    #print(k)
    ok=10**18
    ng=0
    #print(ok,ng)
    while ok-ng>1:
      mid=(ok+ng)//2
      cnt1,cnt2=0,0
      if np>=2:
        for i in range(np):
          cnt1+=bisect_right(ap,mid//ap[i])
          if ap[i]**2<=mid:
            cnt1-=1
      if nn>=2:
        for i in range(nn):
          cnt2+=bisect_right(an,mid//an[i])
          if an[i]**2<=mid:
            cnt2-=1
      if cnt1//2+cnt2//2>=k:
        ok=mid
      else:
        ng=mid
    print(ok)


### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
pos = np.sort(a[a>0])
neg = np.sort(np.abs(a[a<0]))
zero = (a==0).sum()

INF = 2*(10**18)
l = -INF
r = INF

while(r-l>1):
    mid = (l+r)//2
    cnt = 0
    if mid >= 0:
        cnt = len(pos)*len(neg)  #(+) * (-)
        cnt += (len(pos)+len(neg)) * zero # 0 * (non-zero)
        cnt += (zero*(zero-1))//2 # 0 * 0
        x = np.searchsorted(pos, mid//pos, side='right').sum() #(+) * (+)
        x += np.searchsorted(neg, mid//neg, side='right').sum() #(-) * (-)
        x -= (pos*pos<=mid).sum()
        x -= (neg*neg<=mid).sum()
        cnt += x/2
    else:
        #積がmid以上になれば良い -> midよりも小さい
        cnt = (len(neg) - np.searchsorted(neg, abs(mid)//pos + (mid%pos!=0), side='left')).sum()
    #print(mid, cnt)
    #cnt := 積がmid以下になる物の数
    #k番目の数　-> それ以下のものがk個以上ある事が必要
    #cntがk個よりも少ない -> 条件を満たしていない
    #cntがそれ以上ならok
    if cnt < k:
        l = mid
    else:
        r = mid
print(r)
### BUGGY CODE ###

from sys import stdin
input = stdin.readline

def main():
    S = list(input())
    S.pop()
    m = 2019
    div_list = [0]*m
    num = 0
    for i, l in enumerate(reversed(S)):
        num += 10**i*int(l)
        div_list[num%m] += 1

    div_list[0] += 1
    ans = 0
    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
input = stdin.readline

def main():
    S = list(input())
    S.pop()
    m = 2019
    div_list = [0]*m
    num = 0
    for i, l in enumerate(reversed(S)):
        num += pow(10, i, m)*int(l)
        div_list[num%m] += 1

    div_list[0] += 1
    ans = 0
    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

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

n = int(input())
x = input()

val = 0
rui = 1
mod = 0

nagasa = 2*10**5+1
#nagasa = 5
d_li = [0]*(nagasa)

for i in range(1,nagasa):
    t_v = i
    t_m = bin(t_v).count("1")
    ans = 0
    while t_v != 0:
        if d_li[t_v] != 0:
            ans += d_li[t_v]
            break
        ans += 1
        t_v %= t_m
        #t_m = bin(t_v).count("1")
    d_li[i] = ans

#print(d_li)
#exit()
"""
for i in range(n):
    val += int(x[n-1-i])*rui
    rui *= 2
"""
val = int(x, 2)
#print(val)
#exit()

mod = bin(val).count("1")

rui = 2**(n-1)
ans_li = []
    
for i in range(n):
    t_v = val
    t_m = mod
    if int(x[i]) == 1:
        t_v -= rui
        t_m -= 1
    else:
        t_v += rui
        t_m += 1
    rui //= 2
    ans = 0
    #while t_v != 0:
    if t_v != 0:
        t_v %= t_m
        ans += 1
    
    ans += d_li[t_v]
    #t_m = bin(t_v).count("1")
    #ans_li.append(ans)
    print(ans)
    #print(ans_li)
"""
#print(ans_li)
for i in range(n):
    print(ans_li[n-1-i])
"""

### FIXED CODE ###

def main():
    n = int(input())
    x = input()
    
    val = 0
    rui = 1
    mod = 0
    
    nagasa = 2*10**5+1
    #nagasa = 5
    d_li = [0]*(nagasa)
    
    for i in range(1,nagasa):
        t_v = i
        t_m = bin(t_v).count("1")
        ans = 0
        while t_v != 0:
            if d_li[t_v] != 0:
                ans += d_li[t_v]
                break
            ans += 1
            t_v %= t_m
            #t_m = bin(t_v).count("1")
        d_li[i] = ans
    
    #print(d_li)
    #exit()
    """
    for i in range(n):
        val += int(x[n-1-i])*rui
        rui *= 2
    """
    val = int(x, 2)
    #print(val)
    #exit()
    
    mod = bin(val).count("1")
    
    rui = pow(2,(n-1))
    
    t_v_p = val % (mod+1)
    if mod == 1:
        t_v_m = 0
    else:
        t_v_m = val % (mod-1)
        
    for i in range(n):
        ans = 0
        #t_v = val
        #t_m = mod
        if int(x[i]) == 1:
            if mod == 1:
                t_v = 0
            else:
                t_v = t_v_m
                t_v -= pow(2,(n-1-i),mod-1)
                #t_v -= rui % (mod-1)
                t_v %= (mod-1)
                ans += 1
                #t_m -= 1
        else:
            t_v = t_v_p
            t_v += pow(2,(n-1-i),mod+1)
            #print(t_v,rui)
            #t_v += rui % (mod+1)
            t_v %= (mod+1)
            ans += 1
            #t_m += 1
        rui //= 2
        #print(t_v,mod)
        #while t_v != 0:
        """
        if t_v != 0:
            if int(x[i]) == 1:
                if mod == 1:
                    t_v = 0
                else:
                    t_v %= mod-1
            else:
                t_v %= mod + 1
            #t_v %= t_m
            ans += 1
        """
        ans += d_li[t_v]
        #t_m = bin(t_v).count("1")
        #ans_li.append(ans)
        print(ans)
        #print(ans_li)
        
if __name__ == '__main__':
    main()
"""
#print(ans_li)
for i in range(n):
    print(ans_li[n-1-i])
"""
### BUGGY CODE ###

S = input()
MOD = 10**9+7

S = S[::-1]
static = 0
strg = ""
for i,s in enumerate(S):
    if s != "?":
        s = int(s)
        static += s*(10**i)
        strg += "0"
    else:
        strg += "?"
mod = static%13

dp = [0]*13
dp[mod] = 1
for i,s in enumerate(strg):
    new = [0]*13
    if s == "?":
        for j in range(10):
            m = (j*(10**i))%13
            for k in range(13):
                new[k] += dp[k-m]
                new[k] %= MOD
        dp = new
print(dp[5])

### FIXED CODE ###

S = input()
MOD = 10**9+7

dp = [0]*13
dp[0] = 1

for s in S:
    prev = [x for x in dp]
    dp = [0]*13
    if s == "?":
        r = range(10)
    else:
        r = [int(s)]
    for i in range(13):
        for x in r:
            dp[(10*i+x)%13] += prev[i]
    dp = [x % MOD for x in dp]
print(dp[5])
### BUGGY CODE ###

d=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=list(map(int,input().split()))

dp = [-1 for i in range(N+1)]
dp[0] = 0


for i in range(1,N+1):
    tmp = -1
    for a in A:
        if i-a>=0 and dp[i-d[a]] != -1:
            tmp = max(tmp,dp[i-d[a]]+1)
    dp[i] = tmp


A.sort(reverse=True)
ans = ''
while N>0:
    for a in A:
        if N-d[a]>=0 and dp[N-d[a]] == dp[N]-1:
            ans += str(a)
            N -= d[a]
            break
print(ans)





### FIXED CODE ###

d=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=list(map(int,input().split()))

dp = [-1 for i in range(N+1)]
dp[0] = 0


for i in range(1,N+1):
    tmp = -1
    for a in A:
        if i-d[a]>=0 and dp[i-d[a]] != -1:
            tmp = max(tmp,dp[i-d[a]]+1)
    dp[i] = tmp


A.sort(reverse=True)
ans = ''
while N>0:
    for a in A:
        if N-d[a]>=0 and dp[N-d[a]] == dp[N]-1:
            ans += str(a)
            N -= d[a]
            break
print(ans)
### BUGGY CODE ###

import sys

L,R = list(map(int,input().split()))
ans = 2019

if R <= 45:
    print(R*(R-1))
    sys.exit()
else:
    for i in range(L,R):
        for v in range(i+1,R+1):
            a = (i*v)%2019
            ans = min(ans,a)
print(ans)

### FIXED CODE ###

import sys

L,R = list(map(int,input().split()))
ans = 2019

for i in range(L,R):
    for v in range(i+1,R+1):
        a = (i*v)%2019
        ans = min(ans,a)
        if a == 0:
            break
    else:
        continue
    break
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


h, n = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]

INF = 2 ** 64
dprint(INF)
dp = [INF] * (h + 10 ** 4)
dp[0] = 0

for j in range(h):
  for a, b in ab:
    dp[j + a] = min(dp[j + a], dp[j] + b)

dprint(dp[:10])
print(min(dp[h:]))


### FIXED CODE ###

import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


h, n = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]

INF = 2 ** 64
dprint(INF)
dp = [INF] * (h + 10 ** 4)
dp[0] = 0

for j in range(h):
  for a, b in ab:
    dp[j + a] = min(dp[j + a], dp[j] + b)

dprint(dp[:10])
print(min(dp[h:]))
### BUGGY CODE ###

def main():
    from collections import Counter
    import sys

    sys.setrecursionlimit(10 ** 7)
    input = sys.stdin.readline

    def f(c1, c2, c3):
        if checked[c1][c2][c3]:
            return dp[c1][c2][c3]
        checked[c1][c2][c3] = True

        res = (n \
               + (f(c1 - 1, c2, c3) * c1 if c1 else 0) \
               + (f(c1 + 1, c2 - 1, c3) * c2 if c2 else 0) \
               + (f(c1, c2 + 1, c3 - 1) * c3 if c3 else 0)) \
              / (c1 + c2 + c3)

        dp[c1][c2][c3] = res
        return res

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

    c = Counter(a)
    c1 = c[1]
    c2 = c[2]
    c3 = c[3]

    dp = tuple(
        tuple(
            [0.0] * (c3 + 1) for _ in range(c2 + c3 + 1)
        ) for _ in range(c1 + c2 + c3 + 1))
    dp[0][0][0] = 0
    # dp[x][y][z]:=1,2,3個の皿がx,y,z残っているときの期待値

    checked = tuple(
        tuple(
            [False] * (c3 + 1) for _ in range(c2 + c3 + 1)
        ) for _ in range(c1 + c2 + c3 + 1))
    checked[0][0][0] = True

    print(f(c1, c2, c3))


if __name__ == '__main__':
    main()

# dp[now] =
# 1
# + dp[1個の皿を食べた] * p
# + dp[2個の皿を食べた] * p
# + dp[3個の皿を食べた] * p
# + dp[0個の皿を食べた==now] * p

# if mainの追加
# 初期値None->0.0にした
# フラグ配列checkedを追加した


### FIXED CODE ###

def main():
    from collections import Counter

    n = int(input())
    a = tuple(int(x) for x in input().split())

    c = Counter(a)
    c1 = c[1]
    c2 = c[2]
    c3 = c[3]

    x1 = 310 ** 2
    x2 = 310

    dp = [0.0] * (310 ** 3)
    dp[0] = 0.0
    # dp[x * x1 + y * x2 + z]:=1,2,3個の皿がx,y,z残っているときの期待値

    for r3 in range(c3 + 1):
        d3 = c3 - r3
        for r2 in range(c2 + d3 + 1):
            for r1 in range(c1 + d3 + c2 - r2 + 1):
                ind = r1 * x1 + r2 * x2 + r3
                if ind != 0:
                    dp[ind] = (n \
                               + (dp[ind - x1] * r1 if r1 > 0 else 0) \
                               + (dp[ind + x1 - x2] * r2 if r2 > 0 else 0) \
                               + (dp[ind + x2 - 1] * r3 if r3 > 0 else 0)) \
                              / (r1 + r2 + r3)

    print(dp[c1 * x1 + c2 * x2 + c3])


if __name__ == '__main__':
    main()

# dp[now] =
# 1
# + dp[1個の皿を食べた] * p
# + dp[2個の皿を食べた] * p
# + dp[3個の皿を食べた] * p
# + dp[0個の皿を食べた==now] * p

# if mainの追加
# 初期値None->-1.0にした
# checked配列を辞めた
# チェック済みかどうかの判定を-1.0と一致するかの比較にした

# カウントはCounterを使う方が速い
# 1次元にした
# resの加算を複数回に分けると
# 三項演算子より遅くなる
# 再帰関数を辞めた
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 0
num = 0
for k in range(min(a)-1,max(a)+1):
  num = a.count(k)+a.count(k-1)+a.count(k+1)
  ans = max(ans,num)
print(ans)

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
memo = [0]*(10**5+2)
ans = 1
for i in range(N):
  memo[a[i]] += 1
  memo[a[i]+1] += 1
  memo[a[i]-1] += 1
print(max(memo))
### BUGGY CODE ###

import math
N = int(input())

ans = 1
for i in range(1,N+1):
  j = math.sqrt(i)
  if j == int(j):
    ans = i
    
print(ans)

### FIXED CODE ###

import math
N = int(input())

ans = 1
for i in range(1,math.floor(math.sqrt(N))+1):
  if i * i <= N:
    ans = i * i
    
print(ans)
### BUGGY CODE ###

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

a_dic = {}
for i in a:
    if not i in a_dic:
        a_dic[i] = 0
    a_dic[i] += 1
res = 0
for i in a:
    j = 1
    flag = 1
    while j * j <= i:
        if i % j == 0:
            x = j
            if (x == i and a_dic[x] >= 2) or (x != i and x in a_dic and a_dic[x] >= 1):
                flag = 0
                break
            x = i//x
            if (x == i and a_dic[x] >= 2) or (x != i and x in a_dic and a_dic[x] >= 1):
                flag = 0
                break

        j += 1
    # print(flag)
    if flag:
        res += 1

# print(a_dic)
print(res)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
bai = [0 for _ in range(max(a)+1)]
i = 2
for i in a:
    j = i
    while j < len(bai):
        bai[j] += 1
        j += i

res = 0
if n <= 1:
    print(n)
    exit()

for i in range(n):
    if i == 0:
        if a[i] != a[i+1] and bai[a[i]] == 1:
            res += 1
    elif i == n-1:
        if a[i] != a[i-1] and bai[a[i]] == 1:
            res += 1
    else:
        if a[i] != a[i-1] and a[i] != a[i+1] and bai[a[i]] == 1:
            res += 1

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

input()
a=sorted(list(map(int,input().split())))
e=[1 for x in range(10**9+1)]
r=[]
for i in a:
  if e[i]:
    e[i]=0
  else:
    e[i]=1
    r.append(i)
print(0 if len(r) < 2 else r[-1] * r[-2])

### FIXED CODE ###

input()
a=sorted(list(map(int,input().split())))
e={}
r=[]
for i in a:
  if not e.get(i):
    e[i]=1
  else:
    e[i]=0
    r.append(i)
print(0 if len(r) < 2 else r[-1] * r[-2])