#include <stdio.h>
#include <algorithm>

int a[100000];

int main()
{
	int n, m, dosadnost = 0;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] == m)
		{
			a[i] = 0;
		}
	}

	std::sort(a, a + n);
	int j = 0;
	for (int i = 0; i < m; i++)
	{
		while (a[j] <= i && j < n)
		{
			j++;
		}
		if (j >= n)
		{
			break;
		}
		int br = n - j;
		dosadnost += br * (n - br);
	}
	
	printf("%d", dosadnost);
	return 0;
}