#include
#include
#include
#include
using namespace std;
const int maxn = 1e3 + 5;
struct node
{
int v, k, c, l;
bool operator < (const node &a) const
{
return v < a.v;
}
}a[maxn];
int dp[maxn], sum[maxn];
int main()
{
int n;
while(~scanf("%d", &n), n)
{
for(int i = 1; i <= n; i++)
cin >> a[i].v >> a[i].k >> a[i].c >> a[i].l;
sort(a+1, a+1+n);
dp[0] = sum[0] = 0;
for(int i = 1; i <= n; i++)
sum[i] = sum[i-1] + a[i].l;
for(int i = 1; i <= n; i++)
{
dp[i] = sum[i]*a[i].c + a[i].k;
for(int j = i - 1; j >= 1; j--)
dp[i] = min(dp[i], dp[j]+(sum[i]-sum[j])*a[i].c + a[i].k);
}
cout << dp[n] << endl;
}
return 0;
}