# coding: utf-8
# Your code here!


import logging

logging.basicConfig(level=logging.DEBUG)

def update_map(x,y, zaseki_map, tyakuseki_map):

    logging.debug("{0},{1}".format(x,y))
    
    if x - 1 >= 0:
        if tyakuseki_map[x][y] + zaseki_map[x][y] < zaseki_map[x-1][y]:
            zaseki_map[x-1][y] = tyakuseki_map[x][y] + zaseki_map[x][y]
            update_map(x-1, y, zaseki_map, tyakuseki_map)

    if x + 1 < len(zaseki_map):
        if tyakuseki_map[x][y] + zaseki_map[x][y] < zaseki_map[x+1][y]:
            zaseki_map[x+1][y] = tyakuseki_map[x][y] + zaseki_map[x][y]
            update_map(x+1, y, zaseki_map, tyakuseki_map)
    
       
    if y - 1 >= 0:
        if tyakuseki_map[x][y] + zaseki_map[x][y] < zaseki_map[x][y-1]:
            zaseki_map[x][y-1] = tyakuseki_map[x][y] + zaseki_map[x][y]
            update_map(x, y-1, zaseki_map, tyakuseki_map)

    if y + 1 < len(zaseki_map):
        if tyakuseki_map[x][y] + zaseki_map[x][y] < zaseki_map[x][y+1]:
            zaseki_map[x][y+1] = tyakuseki_map[x][y] + zaseki_map[x][y]
            update_map(x, y+1, zaseki_map, tyakuseki_map)
    
    
    
def riseki(p, zaseki_map, tyakuseki_map):
    
    x, y = ((p-1) % len(zaseki_map), int((p-1) / len(zaseki_map)))
    result = zaseki_map[x][y]
    tyakuseki_map[x][y] = 0    
    update_map(x,y, zaseki_map, tyakuseki_map)

    return result


if __name__ == "__main__":
    N = int(input())
    P_list = list(map(int, input().split()))
    
    logging.debug("N:{0}".format(N))
    logging.debug("P:{0}".format(P_list))
        
    
    center = int(N/2)
    zaseki_map = [[0]*N for _ in range(N)]
    tyakuseki_map = [[1]*N for _ in range(N)]
    
    logging.debug(center)
    
    for i in range(N):
        for j in range(N):
            a = i if i < center else (N-1) - i
            b = j if j < center else (N-1) - j
            zaseki_map[i][j] = min(a, b)
    
    for i in zaseki_map:
        logging.debug(i)
        
    
    count = 0
    for p in P_list:
        logging.debug("-----------")
        count += riseki(p, zaseki_map, tyakuseki_map)
        for i in zaseki_map:
            logging.debug(i)
    
    print(count)

    