1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	long long n, inp[5000], obl[5001];
	scanf("%lld", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%lld", inp + i);
	}

	sort(inp, inp + n);
	int maxV = inp[n - 1];
	int maxSum = 0;
	obl[0] = 1;


	for (int i = 1; i <= maxV; i++)
	{
		obl[i] = 0;
	}

	for (int i = 0; i < n; i++)
	{	
		for (int j = maxSum; j >= inp[i]-1; j--)
		{
			int sum = j + inp[i];
			if (sum > maxSum)
			{
				maxSum = sum;
				if (sum >= maxV)
				{
					maxSum = maxV;
				}
			}

			if (sum >= maxV)
			{
				obl[maxV] += obl[j];
				obl[maxV] %= 1000000007ll;
			}
			else
			{
				obl[sum] += obl[j];
				obl[sum] %= 1000000007ll;
			}
		}
	}

	long long res = 0;
	for (int i = 1; i <= maxV; i++) 
	{
		res += obl[i];
		res %= 1000000007ll;
	}


	printf("%lld", res);

	return 0;
}