using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5");
WillReturn.Add("100 150 200 250 300");
//1
}
else if (InputPattern == "Input2") {
WillReturn.Add("13");
WillReturn.Add("243 156 104 280 142 286 196 132 128 195 265 300 130");
//4
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
long[] AArr = InputList[1].Split(' ').Select(pX => long.Parse(pX)).ToArray();
long UB = 1000;
// 場合の数[ カード数 , 和 ]なDP表
long[,] DPArr = new long[5 + 1, 1000 + 1];
DPArr[0, 0] = 1;
foreach (long EachA in AArr) {
for (long I = 4; 0 <= I; I--) {
for (long J = UB; 0 <= J; J--) {
if (DPArr[I, J] == 0) continue;
long NewJ = J + EachA;
if (1000 < NewJ) continue;
DPArr[I + 1, NewJ] += DPArr[I, J];
}
}
}
Console.WriteLine(DPArr[5, 1000]);
}
}