满分代码 """ 测试用例1 6 10 2 6 3 7 8 测试用例2 6 10 9 6 6 7 8 """ n = int(input()) num = list(map(int, input().split())) count = 0 for i in range(n): for j in range(i, n): if abs(num[i] - num[j]) == 1: count += 1 print(count)