#!/usr/bin/env python

def main():
    N = int(input())
    d = list(map(int, input().split()))

    cumSum = [0] * N
    cumSum[0] = d[0]
    for i in range(1, N):
        cumSum[i] = cumSum[i-1] + d[i]

    ans = 0
    for i in range(N-1):
        ans += d[i] * (cumSum[N-1] - cumSum[i])

    print(ans)

if __name__ == '__main__':
    main() def main():
    N = int(input())
    d = list(map(int, input().split()))

    cumSum = [0] * N
    cumSum[0] = d[0]
    for i in range(1, N):
        cumSum[i] = cumSum[i-1] + d[i]

    ans = 0
    for i in range(N-1):
        ans += d[i] * (cumSum[N-1] - cumSum[i])

    print(ans) main N = int(input()) N int(input()) int input() input d = list(map(int, input().split())) d list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cumSum = [0] * N cumSum [0] * N [0] 0 N cumSum[0] = d[0] cumSum[0] cumSum 0 d[0] d 0 for i in range(1, N):
        cumSum[i] = cumSum[i-1] + d[i]

     i range(1, N) range 1 N cumSum[i] = cumSum[i-1] + d[i] cumSum[i] cumSum i cumSum[i-1] + d[i] cumSum[i-1] cumSum i-1 i 1 d[i] d i ans = 0 ans 0 for i in range(N-1):
        ans += d[i] * (cumSum[N-1] - cumSum[i])

     i range(N-1) range N-1 N 1 ans += d[i] * (cumSum[N-1] - cumSum[i]) ans d[i] * (cumSum[N-1] - cumSum[i]) d[i] d i cumSum[N-1] - cumSum[i] cumSum[N-1] cumSum N-1 N 1 cumSum[i] cumSum i print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N = int(input())
    d = list(map(int, input().split()))

    cumSum = [0] * N
    cumSum[0] = d[0]
    for i in range(1, N):
        cumSum[i] = cumSum[i-1] + d[i]

    ans = 0
    for i in range(N-1):
        ans += d[i] * (cumSum[N-1] - cumSum[i])

    print(ans) def main():
    N = int(input())
    d = list(map(int, input().split()))

    cumSum = [0] * N
    cumSum[0] = d[0]
    for i in range(1, N):
        cumSum[i] = cumSum[i-1] + d[i]

    ans = 0
    for i in range(N-1):
        ans += d[i] * (cumSum[N-1] - cumSum[i])

    print(ans) main
#!/usr/bin/env python

def main():
    N = int(input())
    d = list(map(int, input().split()))

    cumSum = [0] * N
    cumSum[0] = d[0]
    for i in range(1, N):
        cumSum[i] = cumSum[i-1] + d[i]

    ans = 0
    for i in range(N-1):
        ans += d[i] * (cumSum[N-1] - cumSum[i])

    print(ans)

if __name__ == '__main__':
    main()