题目分析
```
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
const int N = 210;
int f[N][N] , w[N];
int n;
int main() {
cin >> n;
for (int i = 1; i <= n ; i ++ ) {
cin >> w[i];
w[i + n] = w[i];
}
for (int len = 3 ; len <= n + 1 ; len ++ )
for (int l = 1 ; l <= 2 * n - len + 1; l ++ ) {
int r = l + len - 1;
for (int k = l + 1 ; k < r ; k ++ )
f[l][r] = max(f[l][r] ,f[l][k] + f[k][r] + w[l] * w[k] * w[r]);
}
int res = -0x3f3f3f;
for (int i = 1 ; i <= n ; i ++ ) res = max(res , f[i][n + i]);
cout << res;
return 0;
}
```