from typing import Generic, TypeVar

T = TypeVar("T", default=int)

class FenwickTree(Generic[T]):
    def __init__(self, n: int = 0) -> None: ...
    def add(self, p: int, x: T) -> None: ...
    def sum(self, left: int, right: int) -> T: ...
    def _sum(self, r: int) -> T: ...
