import sys input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) INF = 2 ** 63 - 1 mod = 10 ** 9 + 7 def comp(a): import bisect n = len(a) b = sorted(list(set(a))) c = [] for i in range(n): c.append(bisect.bisect(b, a[i])) return c class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<>i) def get(self,p): assert 0<=p and p>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def max_right(self,l,f): assert 0<=l and l<=self.n assert f(self.e) if l==self.n: return self.n l+=self.size sm=self.e while(1): while(l%2==0): l>>=1 if not(f(self.op(sm,self.d[l]))): while(l1 & (r%2)): r>>=1 if not(f(self.op(self.d[r],sm))): while(r': dp[j][i + 1] += S.prod(a[j] + 1, n + 1) dp[j][i + 1] %= mod else: dp[j][i + 1] += S.prod(0, a[j]) dp[j][i + 1] %= mod ans = 0 for i in range(n + 1): ans += dp[i][k] ans %= mod print(ans)