Mohit(Ex GenSec ) is the most active member of the roasting club who loves giving tasks to other members. One day he observed that none of the members were paying attention to the online classes, so he decided to have some fun and overcome the boring lectures. He wrote N numbers on the virtual board (where the first number is 1, the last one is N and the ith number being i).
Then he asked M questions to every other member of the club. In each question, a number K was given by Mohit and the members had to give a single integer as an answer which will be the sum of all numbers present on the whiteboard.
There are some conditions that every member has to follow while answering.
- If K is already present on the whiteboard then swap the first and last number.
- Otherwise, replace the last number with K.

-----Input:-----
- First-line will consist of space-separated integers N and M. The board will contain the list of numbers from 1 to N and M is the number of questions that Mohit will ask.
- Next M lines contain the number Ki, which will be provided by Mohit and (1<=i<=M).

-----Output:-----
For each question, report the sum of all integers present

-----Constraints-----
- $1 \leq N,M \leq 1000000$
- $2 \leq K \leq 10^9$

-----Sample Input:-----
5 4
7
12 
10 
1  

-----Sample Output:-----
17
22  
20
20

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# cook your dish here\n\nn,m=tuple(map(int,input().split()))\nif(n>2):\n arr=[1,n]\nelif(n==1):\n arr=[1]\nelif(n==2):\n arr=[1,2]\n\nfor i in range(m):\n k=int(input())\n if(n==1):\n  if(k!=arr[0]):\n   arr[0]=k\n  print(arr[0])\n elif(n==2):\n  if(k==arr[0] or k==arr[1]):\n   temp=arr[0]\n   arr[0]=arr[1]\n   arr[1]=temp\n  else:\n   arr[1]=k\n  \n  print(arr[0]+arr[1])\n \n else:\n  ans=int(n*(n+1)/2)-1-n\n  if(k==arr[0] or k==arr[1]):\n   temp=arr[0]\n   arr[0]=arr[1]\n   arr[1]=temp\n  elif(k>1 and k<n):\n   temp=arr[0]\n   arr[0]=arr[1]\n   arr[1]=temp\n  else:\n   arr[1]=k\n  ans+=arr[0]+arr[1]\n  print(ans)\n  \n   \n   \n \n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13515