#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

long long int cal_pattern(int from, int until, int count, std::vector<std::vector<std::vector<long long int>>> &memo, const std::vector<long long int>& pieces, const long long int sum, const long long int y) {
	if (--count < 0) return from == until ? 1 : 0;
	if (memo[from][until][count] >= 0) return memo[from][until][count];
	long long int s = 0;
	long long int result = 0;
	for (auto i = from; i != until; i = (i + 1) % pieces.size()) {
		s += pieces[i];
		if (s + y >= sum / 5) {
			result += cal_pattern((i + 1) % pieces.size(), until, count, memo, pieces, sum, y);
		}
	}
	return memo[from][until][count] = result;
}
long long int solve(const std::vector<long long int>& pieces, const long long int y) {
	const auto sum = std::accumulate(pieces.begin(), pieces.end(), 0LL);
	std::vector<std::vector<std::vector<long long int>>> memo(pieces.size(), std::vector<std::vector<long long int>>(pieces.size(), std::vector<long long int>(5, -1)));
	long long int result = 0;
	for (auto from = 0; from < pieces.size(); ++from) {
		long long int s = pieces[from];
		for (auto size = 1; size < pieces.size(); ++size) {
			if (s + y >= sum / 5) result += cal_pattern((from + size) % pieces.size(), from, 4, memo, pieces, sum, y);
			s += pieces[(from + size) % pieces.size()];
		}
	}
	return result / 5;
}

int main() {
	int n, y; std::cin >> n >> y;
	std::vector<long long int> pieces(n); for (auto& p : pieces) std::cin >> p;
	std::cout << solve(pieces, y) << std::endl;
}
