//其实我觉得不用排序也可以,毕竟每一个的贡献都是那些,不会因为顺序导致,但是不排序可能就偏离题解毕竟是贪心(个人看法)

#include<cstdio>
const int maxn = 110;
int main(){
    int list[maxn];
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &list[i]);
    }
    int score = 0;
    for(int i = 0; i < n-1; i++){
        int temp = list[i] * list[i+1];
        score += temp;
        list[i+1] = list[i] + list[i+1];
    }
    printf("%d\n", score);
    return 0;
}