#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int numv[maxn]; int v[maxn]; int dfs(int idx) { if (idx == 0) return 0; if (idx == 1) return v[0] * v[1]; int max_, a = 0x3f3f3f, b = 0x3f3f3f3f, c = 0; if (idx >= 2) a = (v[idx] * v[idx - 1] + dfs(idx - 2) + numv[idx - 2] * (v[idx] + v[idx - 1])); //与左边粘 b = v[idx] * numv[idx - 1] + dfs(idx - 1); //与左边不粘 c = min(a, b); return c; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &v[i]); if (i == 0) numv[i] = v[i]; numv[i] = numv[i - 1] + v[i]; } printf("%d", dfs(n - 1)); }