https://ac.nowcoder.com/acm/contest/373/B
C++版本一
题解:DP
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=1000000+10;
const int MOD=1e8+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q;
int ans,cnt,flag,temp;
char str;
ll dp[2][N];
int main()
{
#ifdef DEBUG
freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
#endif
scanf("%d",&n);
//scanf("%d",&t);
//while(t--){}
int t=1;
int s=0;
int zero=(N>>1);
int limit=n*666;
dp[1][zero]=1;
for(int i=1;i<=n;i++){
scanf("%d",&k);
for(int j=zero-limit;j<=zero+limit;j++){
dp[s][j]=0;
}
for(int j=zero-limit;j<=zero+limit;j++){
if(dp[t][j]){
dp[s][j+k]=(dp[s][j+k]+dp[t][j])%MOD;
dp[s][zero+666]=0;
dp[s][2*zero-j]=(dp[s][2*zero-j]+dp[t][j])%MOD;
dp[s][zero+666]=0;
}
}
t^=1;
s^=1;
}
cout << dp[t][zero-666] << endl;
//cout << "Hello world!" << endl;
return 0;
}