CF404C Restore Graph

Description

Valera had an undirected connected graph without self-loops and multiple edges consisting of $ n $ vertices. The graph had an interesting property: there were at most $ k $ edges adjacent to each of its vertices. For convenience, we will assume that the graph vertices were indexed by integers from 1 to $ n $ . One day Valera counted the shortest distances from one of the graph vertices to all other ones and wrote them out in array $ d $ . Thus, element $ d[i] $ of the array shows the shortest distance from the vertex Valera chose to vertex number $ i $ . Then something irreparable terrible happened. Valera lost the initial graph. However, he still has the array $ d $ . Help him restore the lost graph.

Input Format

The first line contains two space-separated integers $ n $ and $ k $ $ (1

Output Format

If Valera made a mistake in his notes and the required graph doesn't exist, print in the first line number -1. Otherwise, in the first line print integer $ m $ $ (0