def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    n = int(data[0])
    arr = []
    for i in range(n):
        num = int(data[i + 1])
        arr.append((num, i))
    arr.sort()
    
    total = 0
    for idx in range(n):
        total += abs(arr[idx][1] - idx)
    
    print(total)

if __name__ == "__main__":
    main()