------
## 最终结论
```python
def numSub(s):
    MOD = 10**9 + 7
    count = 0
    total = 0

    for char in s:
        if char == '1':
            count += 1
        else:
            count = 0
        total = (total + count) % MOD

    return total

# Example usage:
# s = "0110111"
# print(numSub(s))  # Output: 9

# s = "101"
# print(numSub(s))  # Output: 2

# s = "111111"
# print(numSub(s))  # Output: 21

# s = "000"
# print(numSub(s))  # Output: 0
```