
    Design an algorithm to determine how many possible heart rhythm patterns of length 2n exist where the sum of abnormal beats in the first half of the monitoring period equals the sum in the second half, with each beat recorded as either normal (0) or abnormal (1). This analysis helps identify stable cardiac patterns where irregularities are evenly distributed across the monitoring session.
    

    
def count_binary_seq(n):
    """
    Design an algorithm to determine how many possible heart rhythm patterns of length 2n exist where the sum of abnormal beats in the first half of the monitoring period equals the sum in the second half, with each beat recorded as either normal (0) or abnormal (1). This analysis helps identify stable cardiac patterns where irregularities are evenly distributed across the monitoring session.
    

    """
def count_binary_seq(n):
    """
    Design an algorithm to determine how many possible heart rhythm patterns of length 2n exist where the sum of abnormal beats in the first half of the monitoring period equals the sum in the second half, with each beat recorded as either normal (0) or abnormal (1). This analysis helps identify stable cardiac patterns where irregularities are evenly distributed across the monitoring session.
    

    """
    nCr = 1
    res = 1
    for r in range(1, n + 1):
        nCr = nCr * (n + 1 - r) / r
        res += nCr * nCr
    return res