#include<stdio.h> 
#include<stdlib.h>
#include<math.h>
  
#define INF 1000000
  
int matrixChainOrder(int *);
  
int aaa,sum;
int mainn[100][100],cap[100],p[101];
  
int matrixChainOrder(int *p){
  int n,l,i,j,k,q;
  
  n = aaa;
  for(i = 1;i <= n;i++){
    mainn[i][i] = 0;
  }
  for(l = 2;l <= n;l++){
    for(i = 1;i <= n-l+1;i++){
      j = i + l - 1;
      mainn[i][j] = INF;
      for(k = i;k <= j-1;k++){
  
    q = mainn[i][k] + mainn[k+1][j] + (p[i-1] * p[k] * p[j]);
  
    mainn[i][j] = (int)fmin(mainn[i][j],q);
  
      }
    }
  }
  
 return mainn[1][n]; 
}
int main(){
  int i,j,n,re;
  
  scanf("%d",&n);
  
  aaa = n;
   
  for(i = 1;i <= n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }
  
  re = matrixChainOrder(p);
  
  printf("%d\n",re);
  
  return 0;
}