import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()


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

    ruiseki = list(itertools.accumulate(d))
    ans = 0
    for i in range(N - 1):
        ans += d[i] * (ruiseki[N - 1] - ruiseki[i])

    print(ans)


if __name__ == '__main__':
    solve() import sys sys import itertools itertools input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def solve():
    N = int(input())
    d = list(map(int, input().split()))

    ruiseki = list(itertools.accumulate(d))
    ans = 0
    for i in range(N - 1):
        ans += d[i] * (ruiseki[N - 1] - ruiseki[i])

    print(ans) solve 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 ruiseki = list(itertools.accumulate(d)) ruiseki list(itertools.accumulate(d)) list itertools.accumulate(d) itertools.accumulate itertools accumulate d ans = 0 ans 0 for i in range(N - 1):
        ans += d[i] * (ruiseki[N - 1] - ruiseki[i])

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

    ruiseki = list(itertools.accumulate(d))
    ans = 0
    for i in range(N - 1):
        ans += d[i] * (ruiseki[N - 1] - ruiseki[i])

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

    ruiseki = list(itertools.accumulate(d))
    ans = 0
    for i in range(N - 1):
        ans += d[i] * (ruiseki[N - 1] - ruiseki[i])

    print(ans) solve input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()


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

    ruiseki = list(itertools.accumulate(d))
    ans = 0
    for i in range(N - 1):
        ans += d[i] * (ruiseki[N - 1] - ruiseki[i])

    print(ans)


if __name__ == '__main__':
    solve()
