Harryxun/stf_run huggingface dataset:
#akash mandal: jalpaiguri government engineering college
import sys,math

def ii(): return int(input())
def mii(): return map(int,input().split())
def lmii(): return list(mii())

def ask(n):
    print(1,n)
    sys.stdout.flush()
    return ii()
    
def decimalToBinary(n):  
    return bin(n).replace("0b", "")  


def main():
    s=input()
    if(s.count("RRR")>0):
        print(3)
        continue
    if(s.count("RR")>0):
        print(2)
        continue
    if(s.count("R")>0):
        print(1)
        continue
    print(0)
        
        
      
        
    
    
    
            
        
            
    
        
if __name__=="__main__":
    main() 

### FIXED CODE ###

#akash mandal: jalpaiguri government engineering college
import sys,math

def ii(): return int(input())
def mii(): return map(int,input().split())
def lmii(): return list(mii())


def main():
    s=input()
    if(s.count("RRR")>0):
        print(3)
    elif(s.count("RR")>0):
        print(2)
    elif(s.count("R")>0):
        print(1)
    else:
        print(0)
        
        
      
        
    
    
    
            
        
            
    
        
if __name__=="__main__":
    main()
import math
n = int(input())

if n%2==0:
  print((n%2)**2)
else:
  print((n+1)%2)*((n+1)%2-1)

### FIXED CODE ###

n = int(input())

e = n//2
o = n-e

print(e*o)
from collections import deque
    H,W=map(int,input().split())
    white=0
    s=[]
    for y in range(H):
        line=input()
        white+=line.count('.')
        s.append(list(line))
     
    q = deque([(0,0,1)])
    q_append=q.append
    q_popleft=q.popleft
    while q:
        x,y,l=q_popleft()
        if s[y][x]!='.':
            continue
        if x==W-1 and y==H-1:
            print(white-l)
            break
        for d in [(1,0),(0,1),(-1,0),(0,-1)]:
            nx, ny=(x+d[0],y+d[1])
            if 0<=nx<W and 0<=ny<H:
                q_append((nx,ny,l+1))
    else:
        print(-1)
        

### FIXED CODE ###

from collections import deque
H,W=map(int,input().split())
white=0
s=[]
for y in range(H):
    line=input()
    white+=line.count('.')
    s.append(list(line))

q = deque([(0,0,1)])
q_append=q.append
q_popleft=q.popleft
while q:
    x,y,l=q_popleft()
    if s[y][x]!='.':
        continue
    if x==W-1 and y==H-1:
        print(white-l)
        break
    s[y][x]='*'
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx, ny=(x+d[0],y+d[1])
        if 0<=nx<W and 0<=ny<H:
            q_append((nx,ny,l+1))
else:
    print(-1)
n = int(input())
s = input()

if n % 2 == 0:
    t = s[0:n/2]
    if s == t + t:
        print("Yes")
        exit()
print("No")
    

### FIXED CODE ###

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

if n % 2 == 0:
    t = s[0:int(n/2)]
    if s == t + t:
        print("Yes")
        exit()
print("No")
# coding: utf-8

from itertools import product as prod
import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f2(K, D):
    l = len(K)
    dp = [[[0] * D for _ in range(2)] for _ in range(l + 1)]
    dp[0][0][0] = 1

    for i, j, d in prod(range(l), range(2), range(D)):
        maxk = 9 if j else int(K[i])
        dpij = dp[i][j]
        dpi1 = dp[i + 1]
        for k in range(maxk + 1):
            dpi1j = dpi1[j or k < maxk]
            d_ = d + k
            if d_ >= D:
                d_ -= D
            dpi1j[d_] += dpij[d]
            if dpi1j[d_] >= mod:
                dpi1j[d_] -= mod
    # K = 0 の場合が含まれるので -1
    return((dp[-1][0][0] + dp[-1][1][0] - 1 + mod) % mod)

K = input().rstrip() # 1 <= K <= 10^10000
D = int(input()) # 1 <= D <= 100

print(f2(K, D))


### FIXED CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f(K, D):
    l = len(K)
    dp = [[[0] * D for _ in range(2)] for _ in range(l + 1)]
    dp[0][0][0] = 1
    for i in range(l):
        ki = int(K[i])
        for j in range(2):
            uki = 9 if j else ki
            dpij = dp[i][j]
            for d in range(D):
                for k in range(uki + 1):
                    dpij_ = dp[i + 1][j or k < ki]
                    d_ = (d + k) % D
                    dpij_[d_] += dpij[d]
                    dpij_[d_] %= mod
    # K = 0 の場合が含まれるので -1
    return((dp[-1][0][0] + dp[-1][1][0] - 1 + mod) % mod)

K = input().rstrip() # 1 <= K <= 10^10000
D = int(input()) # 1 <= D <= 100

print(f(K, D))
a=list(map(int,input().split()))
  print(max(a)-min(a))
         


### FIXED CODE ###

a=list(map(int,input().split()))
print(max(a)-min(a))
a,b=map(int,input().split())
print(int(((a+b)/2)+1)))


### FIXED CODE ###

import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))
n=int(input())
p=map(int,input().split())
count=0
for i in range(0,n-3):
    if (p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>p[i+2]):
        count += 1
print(count)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(0,n-2):
    if (p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>p[i+2]):
        count += 1
print(count)
N,Q=map(int, input().split())
s=input()
S=len(s)
A=[]
for i in range(Q):
  x,y=input().split()
  A.append((x,y))

def L(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    elif s[d]==x and y=='R':
      d+=1
    if d<0:
      return False
  return True

ok,ng=S,-1
mid=(ok+ng)//2
for i in range(50):
  mid=(ok+ng)//2
  if L(mid):
    ok=mid
  else:
    ng=mid
p=ok
if ok==S:
  print(0)
  exit()

def R(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    elif s[d]==x and y=='R':
      d+=1
    if d==S:
      return False
  return True

ok,ng=-1,S
mid=(ok+ng)//2
for i in range(50):
  mid=(ok+ng)//2
  if R(mid):
    ok=mid
  else:
    ng=mid
q=ok
print(q-p+1)

### FIXED CODE ###

N,Q=map(int, input().split())
s=input()
S=len(s)
A=[]
for i in range(Q):
  x,y=input().split()
  A.append((x,y))
  
if N==1:
  for x,y in A:
    if s[0]==x:
      print(0)
      exit()
  print(1)
  exit()
  
def L(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    if s[d]==x and y=='R':
      d+=1
    if d<0:
      return False
    elif d==S:
      d-=1
  return True

ok,ng=S,-1
mid=(ok+ng)//2
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if L(mid):
    ok=mid
  else:
    ng=mid
p=ok
if ok==S:
  print(0)
  exit()

def R(d):
  for x,y in A:
    if s[d]==x and y=='L':
      d-=1    
    if s[d]==x and y=='R':
      d+=1
    if d>=S:
      return False
    elif d<0:
      d+=1
  return True

ok,ng=-1,S
mid=(ok+ng)//2
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if R(mid):
    ok=mid
  else:
    ng=mid
q=ok

print(q-p+1)
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def discount(M, A):
    for _ in range(M):
        A.sort(reverse=True)
        A[0] = int(A[0]/2)
    return sum(A)

def main():
    N, M = filter(int, input().split())
    A = filter(int, input().split())
    discount(M, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def discount(M, A):
    from heapq import heappush, heappop
    hq = []
    for x in A:
        heappush(hq, (-x, x))
    for _ in range(M):
        _, price = heappop(hq)
        dprice = int(price/2)
        heappush(hq, (-dprice, dprice))
    return sum([x for _, x in hq])

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    print(discount(M, A))

if __name__ == '__main__':
    main()
N, *A = map(int, open('0').read().split())
a = max(A)
j = str(A.index(a)+1)
ans = []
if a>0:
  for i,c in enumerate(A):
    if c<0:
      ans.append(j+' '+str(i+1))
  for i in range(1,N):
    ans.append(str(i)+' '+str(i+1))
else:
  for i in range(N,1,-1):
    ans.append(str(i)+' '+str(i-1))
print(len(ans))
print('\n'.join(ans))


### FIXED CODE ###

N = int(input())
a = [int(c) for c in input().split()]
M = max(a)
Mi = a.index(M)
m = min(a)
mi = a.index(m)
ans = []
if 0<=m:
  for i in range(N-1):
    ans += [(i+1, i+2)]
elif M<=0:
  for i in range(N-1, 0, -1):
    ans += [(i+1, i)]
else:
  if abs(m)<abs(M):
    for i in range(N):
      if a[i]<0:
        ans += [(Mi+1, i+1)]
    for i in range(N-1):
      ans += [(i+1, i+2)]
  else:
    for i in range(N):
      if a[i]>0:
        ans += [(mi+1, i+1)]
    for i in range(N-1, 0, -1):
      ans += [(i+1, i)]

print(len(ans))
for c in ans:
  print(*c)
N=int(input())
S=input()
and="No"
if N%2==0:
  first=S[:int(N/2)]
  last=S[int(N/2):]
  if first==last:
    ans="Yes"
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
ans="No"
if N%2==0:
  first=S[:int(N/2)]
  last=S[int(N/2):]
  if first==last:
    ans="Yes"
print(ans)
x = int(input("x????????????"))
print(str(x)+"????????????"+str(x*x*x))

 print(eval(input())**3)

### FIXED CODE ###

x = int(input())
print(x*x*x)
from collections import Counter

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]
    ans=ans+c*counter[c]
print(ans)

### FIXED CODE ###

from collections import Counter

n=int(input())
ans=''
counter={}
for i in range(1,n+1):
    if i==1:
        s=input()
        counter=Counter()
        counter=Counter(s)
    else:
        s=input()
        counter=Counter(s)&counter

for c in [chr(i) for i in range(ord('a'), ord('z')+1)]:
    ans=ans+c*counter[c]
print(ans)
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
# uf = UnionFind(6)
# print(uf.parents)
# # [-1, -1, -1, -1, -1, -1]

# print(uf)

# print(uf.group_count())

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

uf = UnionFind(n)

# print(n, m)
for _ in range(m):
    a, b = map(int, input().split())
    # print(a, b)
    uf.union(a, b)
    
# print(uf.group_count())
print(n - uf.group_count())

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
# uf = UnionFind(6)
# print(uf.parents)
# # [-1, -1, -1, -1, -1, -1]

# print(uf)

# print(uf.group_count())

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

uf = UnionFind(n)

# print(n, m)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    # print(a, b)
    uf.union(a, b)
    
# print(uf.group_count())
print(uf.group_count() - 1)
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def IR_(n): return [II() - 1 for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

# 解説AC
# ナニコレこんなの解けるの？ｗ
# 数え上げはだいたいDP
# ICPCのも水パフォに見えてきた
# このようなDPの問題をもっと解きたい

#solve
def solve():
    n = II()
    c = [n] + IR_(n) + [n]
    dp0 = [0] * (n + 1)
    dp1 = [0] * (n + 1)
    dp1[c[0]] = 1
    for i in range(n + 1):
        if c[i] != c[i + 1]:
            dp0[i] += dp1[c[i]]
            dp0[i] %= mod
            dp1[c[i + 1]] += dp0[i]
            dp1[c[i + 1]] %= mod
        else:
            dp0[i] = dp0[i - 1]
    print(dp0[-1])
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def IR_(n): return [II() - 1 for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

# 解説AC
# ナニコレこんなの解けるの？ｗ
# 数え上げはだいたいDP
# ICPCのも水パフォに見えてきた
# このようなDPの問題をもっと解きたい

#solve
def solve():
    n = II()
    m = 2 * 10 ** 5
    c = [m] + IR_(n) + [m]
    dp0 = [0] * (n + 1)
    dp1 = [0] * (m + 1)
    dp1[c[0]] = 1
    for i in range(n + 1):
        if c[i] != c[i + 1]:
            dp0[i] += dp1[c[i]]
            dp0[i] %= mod
            dp1[c[i + 1]] += dp0[i]
            dp1[c[i + 1]] %= mod
        else:
            dp0[i] = dp0[i - 1]
    print(dp0[-1])
    return


#main
if __name__ == '__main__':
    solve()
dic1 = {" ":"101", "'":"000000", ",":"000011", "-":"10010001", "?":"000001",
        "A":"100101", "B":"10011010", "C":"0101", "D":"0101", "E":"110",
        "F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000",
        "K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101",
        "P":"111", "Q":"10011111", "R":"1000", "S":"00110", "T":"00111",
        "U":"10011100", "V":"10011101", "W":"000010", "X":"10010010", "Y":"10010011", "Z":"10010000"}

dic2 = {"00000":"A", "00001":"B", "00010":"C", "00011":"D", "00100":"E",
        "00101":"F", "00110":"G", "00111":"H", "01000":"I", "01001":"J",
        "01010":"K", "01011":"L", "01100":"M", "01101":"N", "01110":"O",
        "01111":"P", "10000":"Q", "10001":"R", "10010":"S", "10011":"T",
        "10100":"U", "10101":"V", "10110":"W", "10111":"X", "11000":"Y",
        "11001":"Z", "11010":" ", "11011":".", "11100":",", "11101":"-",
        "11110":"'", "11111":"?"}

def to_digit(ss):
  ret = ""
  for s in ss:
    ret += dic1[s]
  return ret

def to_alpha(digit):
  ret = ""
  ind = 0
  end = len(digit)

  while ind + 5 < end:
    ret += dic2[digit[ind:ind + 5]]
    ind += 5

  if digit[ind:]:
    ret += dic2[digit[ind:] + "0" * (5 - end + ind)]

  return ret

while True:
  try:
    ss = input()
    print(to_alpha(to_digit(ss)))
  except EOFError:
    break


### FIXED CODE ###

dic1 = {" ":"101", "'":"000000", ",":"000011", "-":"10010001", ".":"010001", "?":"000001",
        "A":"100101", "B":"10011010", "C":"0101", "D":"0001", "E":"110",
        "F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000",
        "K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101",
        "P":"111", "Q":"10011111", "R":"1000", "S":"00110", "T":"00111",
        "U":"10011100", "V":"10011101", "W":"000010", "X":"10010010", "Y":"10010011", "Z":"10010000"}

dic2 = {"00000":"A", "00001":"B", "00010":"C", "00011":"D", "00100":"E",
        "00101":"F", "00110":"G", "00111":"H", "01000":"I", "01001":"J",
        "01010":"K", "01011":"L", "01100":"M", "01101":"N", "01110":"O",
        "01111":"P", "10000":"Q", "10001":"R", "10010":"S", "10011":"T",
        "10100":"U", "10101":"V", "10110":"W", "10111":"X", "11000":"Y",
        "11001":"Z", "11010":" ", "11011":".", "11100":",", "11101":"-",
        "11110":"'", "11111":"?"}

def to_digit(ss):
  ret = ""
  for s in ss:
    ret += dic1[s]
  return ret

def to_alpha(digit):
  ret = ""
  ind = 0
  end = len(digit)

  while ind + 5 < end:
    ret += dic2[digit[ind:ind + 5]]
    ind += 5

  if digit[ind:]:
    ret += dic2[digit[ind:] + "0" * (5 - end + ind)]

  return ret

while True:
  try:
    print(to_alpha(to_digit(input())))
  except EOFError:
    break
from collections import defaultdict
from collections import deque

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(map(str, input().rstrip()))

cir = defaultdict(deque)
for i in range(k):
    cir[i] = t[i::k]


def solve(li, r, s, p):
    v = []

    def f(li, v):
        if len(li) == 0:
            return 0

        score = 0

        # グーを出す時
        if "r" not in v:
            x = "r"
            if li[0] == "s":
                score = max(score, f(li[1:], ["r"]) + r)
            else:
                score = max(score, f(li[1:], ["r"]))

        # チョキを出す時
        if "s" not in v:
            x = "s"
            if li[0] == "p":
                score = max(score, f(li[1:], ["s"]) + s)
            else:
                score = max(score, f(li[1:], ["s"]))

        # パーを出す時
        if "p" not in v:
            x = "p"
            if li[0] == "r":
                score = max(score, f(li[1:], ["p"]) + p)
            else:
                score = max(score, f(li[1:], ["p"]))

        return score
    return f(li, v)


ans = []
for i in range(k):
    if len(cir[i]) == 0:
        continue
    ans.append(solve(cir[i], r, s, p))

print(sum(ans))

### FIXED CODE ###

from collections import defaultdict

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(map(str, input().rstrip()))

cir = defaultdict(list)
for i in range(k):
    cir[i] = t[i::k]


def solve(sq):
    # 初手
    x = sq[0]
    if x == "r":
        before, score = "r", p
    elif x == "s":
        before, score = "s", r
    else:
        before, score = "p", s
    cnt = 1

    # 前回と違う手なら問答無用で勝てる、前回と同じ手なら奇数回目に勝てる
    for x in sq[1:]:
        if before != x:
            if x == "r":
                score += p
            elif x == "s":
                score += r
            else:
                score += s
            before = x
            cnt = 1
        elif cnt % 2 == 1:
            cnt += 1
        else:
            if x == "r":
                score += p
            elif x == "s":
                score += r
            else:
                score += s
            cnt += 1
    return score


ans = []
for i in range(k):
    ans.append(solve(cir[i]))

print(sum(ans))
n = int(input())
a = [input() for i in range(n)]

c = collections.counter(a)

print(len(c))

### FIXED CODE ###

import collections
n = int(input())
a = [input() for i in range(n)]
list_a = list(a)
c = collections.Counter(a)

print(len(c))
n=int(input())
s=input()
if s[0]==')':
    cnt=1
else:
    cnt=0
for i in range(1,n):
    if s[i]==')' and s[i-1]!='(':
        cnt+=1
    if s[i]==')':
        x=i
print('('*cnt+s+')'*(n-x-1))

### FIXED CODE ###

n=int(input())
s=input()
z=s
while '()' in s:
    s=s.replace('()','')
print('('*s.count(')')+z+')'*s.count('('))
anim, leg = [int(x) for x in input().split()] 

y = (leg - 2anim) / 2
x = (4anim - leg) / 2

if isinstance(y, float) or isinstance(x, float) or y < 0 or x < 0:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

anim, leg = [int(x) for x in input().split()]


y = (leg - 2*anim)  
x = (4*anim - leg)  

if y % 2 == 1 or x % 2 == 1 or y < 0 or x < 0:
    print("No")
else:
    print("Yes")
N = int(input())

if N.count(7) >= 1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
if "7" in n:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-

from functools import lru_cache
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap



def slv(N, A):
    ca = Counter(A)
    s = [[ca[1], ca[2], ca[3]]]
    o = []
    while s:
        c1, c2, c3 = s.pop()
        o.append((c1, c2, c3))
        if c1 > 0:
            s.append((c1-1, c2, c3))
        if c2 > 0:
            s.append((c1+1, c2-1, c3))
        if c3 > 0:
            s.append((c1, c2+1, c3-1))

    memo = defaultdict(lambda: defaultdict(dict))
    memo[0][0][0] = 0
    o.pop()
    while o:
        c1, c2, c3 = o.pop()
        c0 = N - (c1 + c2 + c3)
        p0 = c0 / N
        p1 = c1 / N
        p2 = c2 / N
        p3 = c3 / N
        ip0 = 1 - p0
        ret = 1 / ip0
        if c1 >0:
            ret += memo[c1-1][c2][c3] * p1 / ip0
        if c2 > 0:
            ret += memo[c1+1][c2-1][c3] * p2 / ip0
        if c3 > 0:
            ret += memo[c1][c2+1][c3-1] * p3 / ip0
        memo[c1][c2][c3] = ret


    return memo[ca[1]][ca[2]][ca[3]]

def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))



if __name__ == "__main__":
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.buffer.readline


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def f(c1, c2, c3):
    if memo[c1][c2][c3] != -1:
        return memo[c1][c2][c3]
    c0 = N - (c1 + c2 + c3)
    p0 = c0 / N
    ip0 = 1 - p0
    ret = 1 / ip0
    if c1 > 0:
        p1 = c1 / N
        ret += f(c1-1, c2, c3) * p1 / ip0
    if c2 > 0:
        p2 = c2 / N
        ret += f(c1+1, c2-1, c3) * p2 / ip0
    if c3 > 0:
        p3 = c3 / N
        ret += f(c1, c2+1, c3-1) * p3 / ip0
    memo[c1][c2][c3] = ret
    return ret


N = read_int()
A = read_int_n()
memo = [[[-1] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]
memo[0][0][0] = 0
print(f(A.count(1), A.count(2), A.count(3)))