class Cumsum: def __init__(self,lst,mod=0): self.N=len(lst) self.mod=mod self.cumsum=[0]*(self.N+1) self.cumsum[0]=0 for i in range(1,self.N+1): self.cumsum[i]=self.cumsum[i-1]+lst[i-1] if self.mod: self.cumsum[i]%=self.mod def __getitem__(self,i): if type(i)==int: if 0<=i