砝码称重
import java.util.Scanner;
public class N1447 {
static int N = 100010;// 多开 10 个
static boolean[][] f;
static int[] val;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
// 用多大开多大
val = new int[n + 1];
f = new boolean[n + 1][N]; // f[i][j] 的含义是从前 i 个物品选取(可能为一部分)重量和为 j 的情况是否合理
int sum = 0;// 求总和
for (int i = 1; i <= n; i++) {// 1 ~ n 个物品重量
val[i] = scanner.nextInt();
sum += val[i];
}
f[0][0] = true;
for (int i = 1; i <= n; i++) {// 枚举物品
for (int j = 0; j <= sum; j++) {// 枚举背包
f[i][j] = f[i - 1][j] || f[i - 1][Math.abs(j - val[i])] || f[i - 1][j + val[i]];
// 当前物品可以选择不选、放左边、放右边
}
}
int res = 0;
for (int i = 1; i <= sum; i++) {
if (f[n][i]) {
res++;
}
}
System.out.println(res);
}
}