#include #include typedef long long int int64; #define MIN(a,b) ((a)<(b)?(a):(b)) typedef struct item{ int a,b; } node; int cmp(const void *a,const void *b){ node *p=(node *)a; node *q=(node *)b; return q->b-p->b; } void run(void){ int n; scanf("%d",&n); node *p=(node *)calloc(n,sizeof(node)); int i; for(i=0;i=0;j--){ dp[j+1]=MIN(dp[j+1],dp[j]+p[i].a+p[i].b*j); } } printf("%lld\n",dp[len]); } int main(void){ run(); return 0; }