Fibonacci Numbers of Subset Sums

Sum F[sum(s)] over all K-element subsets s of a set of N distinct numbers, modulo 99991.

Hard8CombinatoricsDynamic programmingMathNumber theoryNo attempts yetTime limit5sMemory limit512 MB

Problem

The Fibonacci numbers are defined as follows.

  • F[1]=1F[1] = 1
  • F[2]=1F[2] = 1
  • F[N]=F[N1]+F[N2]F[N] = F[N-1] + F[N-2] (N3N \ge 3)

You are given a set SS of NN numbers and an integer KK. For every subset ss of SS whose size is KK, take the sum of its elements sum(s)\mathrm{sum}(s), and add up F[sum(s)]F[\mathrm{sum}(s)] over all such subsets. Write a program that computes that total.

For example, take S={1,2,3,4,5}S = \{1, 2, 3, 4, 5\} and K=2K = 2. The subsets of size 2 are {1,2}\{1, 2\}, {1,3}\{1, 3\}, {1,4}\{1, 4\}, {1,5}\{1, 5\}, {2,3}\{2, 3\}, {2,4}\{2, 4\}, {2,5}\{2, 5\}, {3,4}\{3, 4\}, {3,5}\{3, 5\}, {4,5}\{4, 5\}. Their sums are 3, 4, 5, 6, 5, 6, 7, 7, 8, 9 in that order, so the total is F[3]+F[4]+F[5]+F[6]+F[5]+F[6]+F[7]+F[7]+F[8]+F[9]=112F[3] + F[4] + F[5] + F[6] + F[5] + F[6] + F[7] + F[7] + F[8] + F[9] = 112.

Input

The first line contains NN and KK. (1N500001 \le N \le 50\,000, 1KN1 \le K \le N)

The second line contains the NN elements of SS, separated by spaces. Each element is a natural number at most 10910^9, and the elements are distinct.

Output

Print on the first line the sum of F[sum(s)]F[\mathrm{sum}(s)] over every subset ss of size KK, modulo 99991.