public int CalculateDistinctSlices(int[] sequence)
        {
            if (sequence.Length == 0)
            {
                return(0);
            }

            var totalSlices = 0L;
            var slice       = new Slice();

            slice.Add(sequence[0], 0);
            for (int i = 1; i < sequence.Length; i++)
            {
                if (slice.ContainsValue(sequence[i]))
                {
                    totalSlices += GetNumberOfSubSlices(slice.Count);
                    slice.CleanUpToValue(sequence[i]);
                    totalSlices -= GetNumberOfSubSlices(slice.Count);
                }
                slice.Add(sequence[i], i);
            }
            totalSlices += GetNumberOfSubSlices(slice.Count);

            return((int)totalSlices);
        }