#include <bits/stdc++.h>
using namespace std;
int a[100001];
int n;
long long f[100001];
long k=0;
long long ans=0;
int main()
{
cin >> n;
for(int i=1;i<=n;i++)
{
cin >> a[i];
f[i]=f[i-1]+a[i];
}
for(int i=1;i<=n;i++)
{
k+=a[1]*a[i]*i;
}
ans+=k;
for(int i=2;i<=n;i++)
{
k=k-(a[i-1]*a[i-1]);
k=k/a[i-1];
k=k*a[i];
k=k-a[i]*(f[n]-f[i-1]);
ans+=k;
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgYVsxMDAwMDFdOwppbnQgbjsKbG9uZyBsb25nIGZbMTAwMDAxXTsKbG9uZyBrPTA7CmxvbmcgbG9uZyBhbnM9MDsKaW50IG1haW4oKQp7CiAgICBjaW4gPj4gbjsKICAgIGZvcihpbnQgaT0xO2k8PW47aSsrKQogICAgewogICAgICAgIGNpbiA+PiBhW2ldOwogICAgICAgIGZbaV09ZltpLTFdK2FbaV07CiAgICB9CiAgICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgIHsKICAgICAgICBrKz1hWzFdKmFbaV0qaTsKICAgIH0KICAgIGFucys9azsKICAgIGZvcihpbnQgaT0yO2k8PW47aSsrKQogICAgewogICAgICAgIGs9ay0oYVtpLTFdKmFbaS0xXSk7CiAgICAgICAgaz1rL2FbaS0xXTsKICAgICAgICBrPWsqYVtpXTsKICAgICAgICBrPWstYVtpXSooZltuXS1mW2ktMV0pOwogICAgICAgIGFucys9azsKICAgIH0KICAgIGNvdXQgPDwgYW5zOwogICAgcmV0dXJuIDA7Cn0K