def count_subset_sum_recur(arr, total, n):
    """Count subsets given sum by recusrion.

    Time complexity: O(2^n), where n is length of array.
    Space complexity: O(1).
    """
    if total < 0:
        return 0
    if total == 0:
        return 1

    if n < 0:
        return 0

    if total < arr[n]:
        return count_subset_sum_recur(arr, total, n - 1)
    else:
        n_subsets_in = count_subset_sum_recur(arr, total - arr[n], n - 1)
        n_subsets_out = count_subset_sum_recur(arr, total, n - 1)
        return n_subsets_in + n_subsets_out