using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
static int NN => int.Parse(ReadLine());
static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
public static void Main()
{
Solve();
}
static void Solve()
{
var n = NN;
var a = NList;
WriteLine(Except(n, a));
}
static long Except(int n, int[] _a)
{
var a = _a.ToArray();
Array.Sort(a);
var sum = a.Sum();
var max = a[^1];
var dp = new FenwickTree[n + 1][];
for (var i = 0; i < dp.Length; ++i)
{
dp[i] = new FenwickTree[sum + 1];
for (var j = 0; j < dp[i].Length; ++j) dp[i][j] = new FenwickTree(max + 1);
}
dp[0][0].Add(0, 1);
for (var u = 0; u < n; ++u)
{
for (var i = u; i >= 0; --i) for (var j = sum; j >= 0; --j)
{
if (j + a[u] <= sum) dp[i + 1][j + a[u]].Add(a[u], dp[i][j].Sum(a[u]));
}
}
var ans = 0L;
for (var i = 2; i < dp.Length; ++i) for (var j = 0; j < dp[i].Length; ++j) for (var k = 0; k <= max; ++k)
{
if (j % (i - 1) == 0 && k <= j / (i - 1)) ans += dp[i][j].Get(k);
}
return ans;
}
class FenwickTree
{
int size;
long[] tree;
public FenwickTree(int size)
{
this.size = size;
tree = new long[size + 2];
}
public void Add(int index, long value)
{
++index;
for (var x = index; x <= size; x += (x & -x)) tree[x] += value;
}
/// 先頭からindexまでの和(include index)
public long Sum(int index)
{
if (index < 0) return 0;
++index;
var sum = 0L;
for (var x = index; x > 0; x -= (x & -x)) sum += tree[x];
return sum;
}
/// Sum(x) >= value となる最小のxを求める
// 各要素は非負であること
public int LowerBound(long value)
{
if (value < 0) return -1;
var x = 0;
var b = 1;
while (b * 2 <= size) b <<= 1;
for (var k = b; k > 0; k >>= 1)
{
if (x + k <= size && tree[x + k] < value)
{
value -= tree[x + k];
x += k;
}
}
return x;
}
public long Get(int index)
{
return index == 0 ? Sum(0) : (Sum(index) - Sum(index - 1));
}
}
}