#abc346c. C - Σ

C - Σ

Score: 250250 points

问题陈述

给定一个正整数序列 A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N),长度为 NN,以及一个正整数 KK

找出在序列 AA 中不出现的、介于 11KK(包括 11KK)之间的整数的和。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are given a sequence of positive integers A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N) of length NN and a positive integer KK.

Find the sum of the integers between 11 and KK, inclusive, that do not appear in the sequence AA.

Constraints

  • 1N2×1051\leq N \leq 2\times 10^5
  • 1K2×1091\leq K \leq 2\times 10^9
  • 1Ai2×1091\leq A_i \leq 2\times 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \dots ANA_N

Output

Print the answer.

Sample Input 1

4 5
1 6 3 1

Sample Output 1

11

Among the integers between 11 and 55, three numbers, 22, 44, and 55, do not appear in AA.

Thus, print their sum: 2+4+5=112+4+5=11.

Sample Input 2

1 3
346

Sample Output 2

6

Sample Input 3

10 158260522
877914575 24979445 623690081 262703497 24979445 1822804784 1430302156 1161735902 923078537 1189330739

Sample Output 3

12523196466007058

update @ 2024/5/16 17:17:51