


syouhi0 consumed [] = 0
syouhi0 consumed (x:xs) = syouhi1 0 (x:consumed) xs + syouhi0 consumed xs

syouhi1 diff consumed [] = 0
syouhi1 diff consumed (x:xs) = if x`elem`consumed
                                    then syouhi1 (diff+1) consumed xs
                                    else syouhi2 diff 0 (x:consumed) xs + syouhi1 (diff+1) consumed xs

syouhi2 diff_past diff_current consumed [] = 0
syouhi2 diff_past diff_current consumed (x:xs) = if x`elem`consumed
                                             then syouhi2 diff_past (diff_current+1) consumed xs
                                             else if (diff_past/=diff_current)
                                               then 1 + syouhi2 diff_past (diff_current+1) consumed xs
                                               else syouhi2 diff_past (diff_current+1) consumed xs



someFunc = do
  n <- read<$>getLine :: IO Int
  s<-getLine
  print $ syouhi0 [] s