#E.py
import sys
#sys.stdin = open('E.in')

from bisect import bisect, bisect_left
from collections import defaultdict

def main():
    add_dict = defaultdict(list)
    del_dict = defaultdict(list)

    n = int(raw_input())
    for i in range(n):
        a, t, x = [ord(k)-48 for k in raw_input().split()]
        if a == 1:
            #add
            idx = bisect(add_dict[x], t)
            add_dict[x].insert(idx, t)
        elif a == 2:
            # del
            idx = bisect(del_dict[x], t)
            del_dict[x].insert(idx, t)

        else:
            idx_add = bisect(add_dict[x], t)
            idx_del = bisect(del_dict[x], t)
            print idx_add - idx_del
main()


#E.py
import sys
sys.stdin = open('E.in')

from bisect import bisect, bisect_left
from collections import defaultdict

def main():
    add_dict = defaultdict(list)
    del_dict = defaultdict(list)

    n = int(raw_input())
    for i in range(n):
        a, t, x = [ord(k)-48 for k in raw_input().split()]
        if a == 1:
            #add
            idx = bisect(add_dict[x], t)
            add_dict[x].insert(idx, t)
        elif a == 2:
            # del
            idx = bisect(del_dict[x], t)
            del_dict[x].insert(idx, t)

        else:
            idx_add = bisect(add_dict[x], t)
            idx_del = bisect(del_dict[x], t)
            print idx_add - idx_del
main()


#E.py
import sys
#sys.stdin = open('E.in')

from bisect import bisect, bisect_left
from collections import defaultdict

def main():
    num_dict = defaultdict(list)
    n = int(raw_input())
    for i in range(n):
        a, t, x = [int(k) for k in raw_input().split()]
        if a == 1:
            #add
            idx = bisect(num_dict[x], t)
            num_dict[x].insert(idx, t)
        elif a == 2:
            # del
            idx = bisect(num_dict[x], t)
            #print num_dict[x], t, idx
            del num_dict[x][idx-1]
        else:
            idx = bisect(num_dict[x], t)
            print idx
main()


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"sort"
)

func main() {
	defer out.Flush()
	Q := in.NextInt()
	qs := make([]Query, Q)
	xTimes := make(map[int][]int)
	for i := range qs {
		qs[i].a = in.NextInt()
		qs[i].t = in.NextInt()
		qs[i].x = in.NextInt()
		xTimes[qs[i].x] = append(xTimes[qs[i].x], qs[i].t)
	}
	timeToXTime := make(map[int]int)
	fs := make(map[int]*Fenwick)
	for x, times := range xTimes {
		sort.Ints(times)
		for i, t := range times {
			timeToXTime[t] = i
		}
		fs[x] = NewFenwick(len(times))
	}
	for i := range qs {
		q := qs[i]
		f := fs[q.x]
		xt := timeToXTime[q.t]
		switch q.a {
		case 1:
			f.Set(xt, 1)
		case 2:
			f.Set(xt, -1)
		case 3:
			fmt.Fprintln(out, f.Sum(0, xt))
		}
	}
}

type Query struct {
	a, t, x int
}

type Fenwick struct {
	size int
	sum  []int
}

func NewFenwick(size int) *Fenwick {
	return &Fenwick{
		size,
		make([]int, size+1),
	}
}

func step(x int) int {
	return x & -x
}

func (f *Fenwick) Add(pos int, value int) {
	for i := pos + 1; i <= f.size; i += step(i) {
		f.sum[i] += value
	}
}

func (f *Fenwick) Set(pos int, value int) {
	f.Add(pos, value-f.Get(pos))
}

func (f *Fenwick) prefixSum(pos int) int {
	var result int
	for i := pos + 1; i > 0; i -= step(i) {
		result += f.sum[i]
	}
	return result
}

func (f *Fenwick) Sum(a, b int) int {
	return f.prefixSum(b) - f.prefixSum(a-1)
}

func (f *Fenwick) Get(a int) int {
	return f.Sum(a, a)
}

var (
	in  = NewFastReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

type FastReader struct {
	r   *bufio.Reader
	buf string
}

func NewFastReader(r io.Reader) *FastReader {
	return &FastReader{
		r: bufio.NewReader(r),
	}
}

func (r *FastReader) advance() {
	for len(r.buf) != 0 && r.buf[0] == ' ' {
		r.buf = r.buf[1:]
	}
	var err error
	for len(r.buf) == 0 && err != io.EOF {
		buf := new(bytes.Buffer)
		for {
			var chunk []byte
			var more bool
			chunk, more, err = r.r.ReadLine()
			buf.Write(chunk)
			if !more {
				break
			}
		}
		r.buf = buf.String()
	}
}

func (r *FastReader) NextLine() string {
	r.advance()
	line := r.buf
	r.buf = ""
	return line
}

func (r *FastReader) NextWord() string {
	r.advance()
	var word string
	wordStart := 0
	for i := 0; i < len(r.buf); i++ {
		b := r.buf[i]
		if b == ' ' {
			if i != wordStart {
				word = r.buf[wordStart:i]
				r.buf = r.buf[i:]
				break
			}
			wordStart = i + 1
		}
	}
	if len(word) == 0 {
		word = r.buf
		r.buf = ""
	}
	return word
}

func (r *FastReader) NextInt() int {
	return parseInt(r.NextWord())
}

func parseInt(word string) int {
	sign := 1
	if word[0] == '-' {
		sign = -1
		word = word[1:]
	}
	result := 0
	for i := 0; i < len(word); i++ {
		result = result*10 + int(word[i]) - '0'
	}
	result *= sign
	return result
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

int main()
{
    int n,s,t;
    cin>>n;
    int i,j;
   int m=-1,mi;
    char na[21];
    int c[51];
    string f;
 for(i=0;i<n;i++)
 {
                cin>>na;
                s=0;
           cin>>t;
            s=s+(t*100);
           cin>>t;
           s=s-(t*50);
           for(j=0;j<5;j++)
           {
                           cin>>t;
                           s+=t;
                           }

                 c[i]=s;
                 if(c[i]>m)
                 {
                            m=c[i];
                            f="";
                            f+=na;
                            }
                 }

                cout<<f;
                //cin>>n;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
using namespace std;

int main()
{
    int n,s,t;
    cin>>n;
    int i,j;
   int m=-1,mi;
    char na[21];
    int c[51],k;
  char car[21];
 for(i=0;i<n;i++)
 {
                cin>>na;
                s=0;
           cin>>t;
            s=s+(t*100);
           cin>>t;
           s=s-(t*50);
           for(j=0;j<5;j++)
           {
                           cin>>t;
                           s+=t;
                           }

                 c[i]=s;
               //  cout<<s<<endl;
                 if(c[i]>m)
                 {
                            m=c[i];
                           // f="";
                            //f+=na;
                            for(k=0;k<=strlen(na);k++)
                            car[k]=na[k];

                            //c[k]='\o';
                            }
                 }

                //cout<<f;
                cout<<car<<endl;
                //cin>>n;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>

using namespace std;

int main()
{
    int n,s,t;
    cin>>n;
    int i,j;
   int m,mi;
m=1<<32;
    char na[21];
    int c[51],k;
  char car[21];
 for(i=0;i<n;i++)
 {
                cin>>na;
                s=0;
           cin>>t;
            s=s+(t*100);
           cin>>t;
           s=s-(t*50);
           for(j=0;j<5;j++)
           {
                           cin>>t;
                           s+=t;
                           }

                 c[i]=s;
               //  cout<<s<<endl;
                 if(c[i]>m)
                 {
                            m=c[i];
                           // f="";
                            //f+=na;
                            for(k=0;k<=strlen(na);k++)
                            car[k]=na[k];

                            //c[k]='\o';
                            }
                 }

                //cout<<f;
                cout<<car<<endl;
                //cin>>n;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>

using namespace std;

int main()
{
    int n,s,t;
    cin>>n;
    int i,j;
   int m=-1,mi;
    char na[21];
    int c[51],k;
  char car[21];
 for(i=0;i<n;i++)
 {
                cin>>na;
                s=0;
           cin>>t;
            s=s+(t*100);
           cin>>t;
           s=s-(t*50);
           for(j=0;j<5;j++)
           {
                           cin>>t;
                           s+=t;
                           }

                 c[i]=s;
               //  cout<<s<<endl;
                 if(c[i]>m)
                 {
                            m=c[i];
                           // f="";
                            //f+=na;
                            for(k=0;k<=strlen(na);k++)
                            car[k]=na[k];

                            //c[k]='\o';
                            }
                 }

                //cout<<f;
                cout<<car<<endl;
                //cin>>n;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

int main()
{
    int n,s,t;
    cin>>n;
    int i,j;
   int m=-1,mi;
    char na[21];
    int c[51];
    string f;
 for(i=0;i<n;i++)
 {
                cin>>na;
                s=0;
           cin>>t;
            s=s+(t*100);
           cin>>t;
           s=s-(t*50);
           for(j=0;j<5;j++)
           {
                           cin>>t;
                           s+=t;
                           }

                 c[i]=s;
                 if(c[i]>m)
                 {
                            m=c[i];
                            f="";
                            f+=na;
                            }
                 }

                cout<<f<<endl;
                //cin>>n;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>

using namespace std;

int main()
{
    int n,s,t;
    cin>>n;
    int i,j;
   int m,mi;
m=-1000000000;
    char na[21];
    int c[51],k;
  char car[21];
 for(i=0;i<n;i++)
 {
                cin>>na;
                s=0;
           cin>>t;
            s=s+(t*100);
           cin>>t;
           s=s-(t*50);
           for(j=0;j<5;j++)
           {
                           cin>>t;
                           s+=t;
                           }

                 c[i]=s;
               //  cout<<s<<endl;
                 if(c[i]>m)
                 {
                            m=c[i];
                           // f="";
                            //f+=na;
                            for(k=0;k<=strlen(na);k++)
                            car[k]=na[k];

                            //c[k]='\o';
                            }
                 }

                //cout<<f;
                cout<<car<<endl;
                //cin>>n;
}


#include<iostream>
using namespace std;
int main()
{
int n,i,j;
long int max=0;
char hn[50][21];
cin>>n;
int *p= new int [n];
int *m= new int [n];
int *a= new int [n];
int *b= new int [n];
int *c= new int [n];
int *d= new int [n];
int *e= new int [n];
long int *po= new long int [n];
for(i=0; i<n; i++)
cin>>hn[i]>>p[i]>>m[i]>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
for(i=0; i<n; i++)
{
po[i]=100*p[i]-50*m[i]+a[i]+b[i]+c[i]+d[i]+e[i];
if(max<po[i])
{
j=i;
max=po[i];
}
}
cout<<hn[j];
delete po;
delete p;
delete m;
delete a;
delete b;
delete c;
delete d;
delete e;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
char hn[50][21];
cin>>n;
int *p= new int [n];
int *m= new int [n];
int *a= new int [n];
int *b= new int [n];
int *c= new int [n];
int *d= new int [n];
int *e= new int [n];
long int *po= new long int [n];
for(i=0; i<n; i++)
cin>>hn[i]>>p[i]>>m[i]>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
for(i=0; i<n; i++)
{
po[i]=100*p[i]-50*m[i]+a[i]+b[i]+c[i]+d[i]+e[i];
if(max<po[i])
{
j=i;
max=po[i];
}
}
cout<<hn[j];
delete po;
delete p;
delete m;
delete a;
delete b;
delete c;
delete d;
delete e;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,i,j;
char hn[50][21];
cin>>n;
int *p= new int [n];
int *m= new int [n];
int *a= new int [n];
int *b= new int [n];
int *c= new int [n];
int *d= new int [n];
int *e= new int [n];
long int *po= new long int [n];
for(i=0; i<n; i++)
cin>>hn[i]>>p[i]>>m[i]>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
for(i=0; i<n; i++)
{
po[i]=100*p[i]-50*m[i]+a[i]+b[i]+c[i]+d[i]+e[i];
if(max<po[i])
{
j=i;
max=po[i];
}
}
cout<<hn[j];
delete po;
delete p;
delete m;
delete a;
delete b;
delete c;
delete d;
delete e;
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,i,j;
long int max;
char hn[50][21];
cin>>n;
int *p= new int [n];
int *m= new int [n];
int *a= new int [n];
int *b= new int [n];
int *c= new int [n];
int *d= new int [n];
int *e= new int [n];
long int *po= new long int [n];
for(i=0; i<n; i++)
cin>>hn[i]>>p[i]>>m[i]>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
i=0;
max=100*p[i]-50*m[i]+a[i]+b[i]+c[i]+d[i]+e[i];
j=0;
for(++i; i<n; i++)
{
po[i]=100*p[i]-50*m[i]+a[i]+b[i]+c[i]+d[i]+e[i];
if(max<po[i])
{
j=i;
max=po[i];
}
}
cout<<hn[j];
delete po;
delete p;
delete m;
delete a;
delete b;
delete c;
delete d;
delete e;
return 0;
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<list>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<deque>
#include<set>
#include<cstring>
#include<map>
#include<sstream>

#define abs(a) ( (a<0)? (-a): (a) )
#define sqr(a) ( (a)*(a) )

const int inf = int(2e-9);

using namespace std;

int main()
{
	int n, m = -1000000000;
	string q;
	cin >> n;
	for (int i = 0; i<n; i++)
	{
		string x;
		int b1,b2,a1,a2,a3,a4,a5;
		cin >> x >> b1 >> b2 >> a1 >> a2 >> a3 >> a4 >> a5;
		int s = (b1*100)-(b2*50)+a1+a2+a3+a4+a5;
		if (s > m) {m = s; q = x;};
	}
	cout << q;
       	return 0;
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<list>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<deque>
#include<set>
#include<cstring>
#include<map>
#include<sstream>

#define abs(a) ( (a<0)? (-a): (a) )
#define sqr(a) ( (a)*(a) )

const int inf = int(2e-9);

using namespace std;

int main()
{
	int n;
	cin >> n;
	map <string, int> m;
	for (int i = 0; i<n; i++)
	{
		string x;
		int b1,b2,a1,a2,a3,a4,a5;
		cin >> x >> b1 >> b2 >> a1 >> a2 >> a3 >> a4 >> a5;
		int s = (b1*100)-(b2*50)+a1+a2+a3+a4+a5;
		m[x] = s;
	}
	map <string, int> :: iterator i;
	i = m.end();
	i--;
	cout << (*i).first;
       	return 0;
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<list>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<deque>
#include<set>
#include<cstring>
#include<map>
#include<sstream>

#define abs(a) ( (a<0)? (-a): (a) )
#define sqr(a) ( (a)*(a) )

const int inf = int(2e-9);

using namespace std;

int main()
{
	int n, m = -inf;
	string q;
	cin >> n;
	for (int i = 0; i<n; i++)
	{
		string x;
		int b1,b2,a1,a2,a3,a4,a5;
		cin >> x >> b1 >> b2 >> a1 >> a2 >> a3 >> a4 >> a5;
		int s = (b1*100)-(b2*50)+a1+a2+a3+a4+a5;
		if (s > m) {m = s; q = x;};
	}
	cout << q;
       	return 0;
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<list>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<deque>
#include<set>
#include<cstring>
#include<map>
#include<sstream>

#define abs(a) ( (a<0)? (-a): (a) )
#define sqr(a) ( (a)*(a) )

const int inf = int(2e-9);

using namespace std;

int main()
{
	int n, m = -1000000000;
	string q;
	cin >> n;
	cout << m;
	for (int i = 0; i<n; i++)
	{
		string x;
		int b1,b2,a1,a2,a3,a4,a5;
		cin >> x >> b1 >> b2 >> a1 >> a2 >> a3 >> a4 >> a5;
		int s = (b1*100)-(b2*50)+a1+a2+a3+a4+a5;
		if (s > m) {m = s; q = x;};
	}
	cout << q;
       	return 0;
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
    long long int i,j,k=1,m,n,b,c=1,a,sum=0,d,e,plus,minus;
    long long int s[100000];
    char name[250][250];
    char max[300];
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>name[i]>>plus>>minus>>a>>b>>c>>d>>e;
    s[i]=(plus*100)-(minus*50)+(a+b+c+d+e);
    if(i>1 && s[i]>s[k])
        {
     k=i;
    }

    }
    cout<<name[k];

return 0;
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
    long long int i,j,k,m,n,b,c=1,a,sum=0,d,e,plus,minus;
    long long int s[100000];
    char name[250][250];
    char max[300];
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>name[i]>>plus>>minus>>a>>b>>c>>d>>e;
    s[i]=plus*100-minus*50+a+b+c+d+e;
    if(i>1 && s[i]>s[i-1])
        {
      strcpy(max,name[i]);
    }

    }
    cout<<max;

return 0;
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
    long long int i,j,k,m,n,b,c=1,a,sum=0,d,e,plus,minus;
    long long int s[100000];
    char name[250][250];
    char max[300];
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>name[i]>>plus>>minus>>a>>b>>c>>d>>e;
    s[i]=plus*100-minus*50+a+b+c+d+e;
    if(i>1 && s[i]>s[i-1])
        {
     k=i;
    }

    }
    cout<<name[k];

return 0;
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
    long long int i,j,k,m,n,b,c=1,a,sum=0,d,e,plus,minus;
    long long int s[100000];
    char name[250][250];
    char max[300];
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>name[i]>>plus>>minus>>a>>b>>c>>d>>e;
    s[i]=(plus*100)-(minus*50)+(a+b+c+d+e);
    if(i>1 && s[i]>s[i-1])
        {
     k=i;
    }

    }
    cout<<name[k];

return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    string k,ass;
    int n,butt=0,hack,nohack,q1,q2,q3,q4,q5,cow=-1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin >> k;
        cin >>hack>>nohack>>q1>>q2>>q3>>q4>>q5;
        butt +=100*hack;
        butt -=50*nohack;
        butt +=q1;
        butt +=q2;
        butt +=q3;
        butt +=q4;
        butt +=q5;
        if(butt>cow){
            cow=butt;
            ass=k;
            }
        butt=0;

    }
    cout<<ass;
    return 0;
}


#include <iostream>
#include<string>
#include<map>

using namespace std;

int main()
{
    map<int,string>kakyoin;
    string s,butt;
    int n,a[50][7],points=0,jojo=-1,lerolero=0;
    cin >> n;
    for(int i=0;i<n;i++){
            cin >>s;
            kakyoin[lerolero]=s;
            a[i][0]=lerolero;
            lerolero++;
        for(int j=1;j<=7;j++)
            cin >>a[i][j];

    }
    for(int i=0;i<n;i++){
        int j=1;
        if(a[i][j]>0)
            points +=100*a[i][j];
        if(a[i][j+1]>0)
            points -=50*a[i][j+1];
        if(a[i][j+2]>0)
            points +=a[i][j+2];
        if(a[i][j+3]>0)
            points+=a[i][j+3];
        if(a[i][j+4]>0)
            points+=a[i][j+4];
        if(a[i][j+5]>0)
            points+=a[i][j+5];
        if(a[i][j+6]>0)
            points+=a[i][j+6];

        if(jojo<points){
            jojo=points;
            butt=kakyoin[i];
            }
        points=0;

    }
    cout << butt;

    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    string k,ass;
    int n,butt=0,hack,nohack,q1,q2,q3,q4,q5,cow=-10000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin >> k;
        cin >>hack>>nohack>>q1>>q2>>q3>>q4>>q5;
        butt +=100*hack;
        butt -=50*nohack;
        butt +=q1;
        butt +=q2;
        butt +=q3;
        butt +=q4;
        butt +=q5;
        if(butt>cow){
            cow=butt;
            ass=k;
            }
        butt=0;

    }
    cout<<ass;
    return 0;
}


#include <iostream>
#include<string>
#include<map>

using namespace std;

int main()
{
    map<int,string>kakyoin;
    string s,butt;
    int n,a[7][50],points,jojo=-1,lerolero=0;
    cin >> n;
    for(int i=0;i<n;i++)
        for(int j=1;j<n;j++){
            cin >>s;
            a[i][0]=lerolero;
            kakyoin[lerolero]=s;
            cin >>a[i][j];
            lerolero++;
            }
    for(int i=0;i<n;i++){
        int j=1;
        if(a[i][j]>0)
            points +=100*a[i][j];
        if(a[i][j+1]>0)
            points -=50*a[i][j+1];
        if(a[i][j+2]>0)
            points +=a[i][j+2];
        if(a[i][j+3]>0)
            points+=a[i][j+3];
        if(a[i][j+4]>0)
            points+=a[i][j+4];
        if(a[i][j+5]>0)
            points+=a[i][j+5];
        if(a[i][j+6]>0)
            points+=a[i][j+6];

        if(jojo<points)
            jojo=points;
            butt=kakyoin[i];

    }
    cout << butt;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, i, x, y, A, B, C, D, E, jumlah, maks=0;
	scanf ("%d", &N);
	char handle[30], ans[30];
	for (i=0; i<N; i++) {
		scanf ("%s %d %d %d %d %d %d %d", &handle, &x, &y, &A, &B, &C, &D, &E);
		jumlah = A+B+C+D+E+(100*x)-(50*y);
		if (jumlah>maks) {
			maks = jumlah; strcpy(ans,handle);
		}
	}
	printf ("%s\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, i, x, y, A, B, C, D, E, jumlah, maks=-3000;
	scanf ("%d", &N);
	char handle[30], ans[30];
	for (i=0; i<N; i++) {
		scanf ("%s %d %d %d %d %d %d %d", &handle, &x, &y, &A, &B, &C, &D, &E);
		jumlah = A+B+C+D+E+(100*x)-(50*y);
		if (jumlah>maks) {
			maks = jumlah; strcpy(ans,handle);
		}
	}
	printf ("%s\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, i, x, y, A, B, C, D, E, jumlah, maks=0;
	scanf ("%d", &N);
	char handle[20], ans[20];
	for (i=0; i<N; i++) {
		jumlah = 0;
		scanf ("%s %d %d %d %d %d %d %d", &handle, &x, &y, &A, &B, &C, &D, &E);
		jumlah+= A+B+C+D+E+(100*x)-(50*y);
		if (jumlah>maks) {
			maks = jumlah; strcpy(ans,handle);
		}
	}
	printf ("%s\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, i, x, y, A, B, C, D, E, jumlah, maks=0;
	scanf ("%d", &N);
	char handle[20], ans[20];
	for (i=0; i<N; i++) {
		scanf ("%s %d %d %d %d %d %d %d", &handle, &x, &y, &A, &B, &C, &D, &E);
		jumlah = A+B+C+D+E+(100*x)-(50*y);
		if (jumlah>maks) {
			maks = jumlah; strcpy(ans,handle);
		}
	}
	printf ("%s\n", ans);
	return 0;
}


//abo  masteriiiii
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int a,s,d,f,g,h,j,k,l,n,i;
string z,x;
main(){
cin>>n;
for(i=0;i<n;i++){
cin>>z>>a>>s>>d>>f>>g>>h>>j;
k=100*a-50*s+d+f+g+h+j;
if(k>l || l==0) {l=k;x=z;}}
cout<<x;
  system("pause");
}


abo  masteriiiii
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int a,s,d,f,g,h,j,k,l,n,i;
string z,x;
main(){
cin>>n;
for(i=0;i<n;i++){
cin>>z>>a>>s>>d>>f>>g>>h>>j;
k=100*a-50*s+d+f+g+h+j;
if(k>l || l==0) {l=k;x=z;}}
cout<<x;
  system("pause");
}


//abo  masteriiiii
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int a,s,d,f,g,h,j,k,l,n,i;
string z,x;
main(){
cin>>n;
for(i=0;i<n;i++){
cin>>z>>a>>s>>d>>f>>g>>h>>j;
k=100*a-50*s+d+f+g+h+j;
if(k>l || l==0) {l=k;x=z;}}
cout<<x;
  //system("pause");
}


//abo masteriiii
#include<iostream>
#include<string>
using namespace std;
int a,s,d,f,g,h,j,k,l,n,i;
string z,x;
  main(){
      cin>>n;
          for(i=0;i<n;i++){
           cin>>z>>a>>s>>d>>f>>g>>h>>j;
             k=100*a-50*s+d+f+g+h+j;
          if(k>l || i==0) {
          l=k;x=z;
          }
          }
        cout<<x;
//system("pause");
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,biggest=0,number=0;
    cin >>n;
    string names [50];
    int hacksp[50],hacksm[50],a[50],b[50],c[50],d[50],e[50],sum[50];
    int counter;
    for(counter=0;counter<n;counter++)
    {
        cin >>names[counter]>>hacksp[counter]>>hacksm[counter]>>a[counter]>>b[counter]
            >>c[counter]>>d[counter]>>e[counter];
        sum [counter] =hacksp[counter]*50-hacksm[counter]*50+a[counter]+b[counter]
        +c[counter]+d[counter]+e[counter];

        biggest = max(sum [counter],biggest);

    }
     while (counter--)
    {
        if (sum[counter]==biggest)
            number=counter;
    }
    cout << names[number];

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,biggest=0,number=0;
    cin >>n;
    string names [50];
    int hacksp[50],hacksm[50],a[50],b[50],c[50],d[50],e[50],sum[50];
    int counter;
    for(counter=0;counter<n;counter++)
    {
        cin >>names[counter]>>hacksp[counter]>>hacksm[counter]>>a[counter]>>b[counter]
            >>c[counter]>>d[counter]>>e[counter];
        sum [counter] =hacksp[counter]*100-hacksm[counter]*50+a[counter]+b[counter]
        +c[counter]+d[counter]+e[counter];

        biggest = max(sum [counter],biggest);

    }
     while (counter--)
    {
        if (sum[counter]==biggest)
            number=counter;
    }
    cout << names[number];

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,biggest=0,number=0;
    cin >>n;
    string names [50];
    int hacksp[50],hacksm[50],a[50],b[50],c[50],d[50],e[50],sum[50];
    int counter;
    for(counter=0;counter<n;counter++)
    {
        cin >>names[counter]>>hacksp[counter]>>hacksm[counter]>>a[counter]>>b[counter]
            >>c[counter]>>d[counter]>>e[counter];
        sum [counter] =hacksp[counter]*100-hacksm[counter]*50+a[counter]+b[counter]
        +c[counter]+d[counter]+e[counter];
        int positive=0;
        for (int a=0;a<n;a++)
        {
            if (sum[a]<0)
                positive++;

        if (positive==n-1)
        {
            for (int b=0;b<n;b++)
            {
                sum [b]=sum[b]*-1;
            }
            biggest = min(sum [counter],biggest);
        }
        else biggest = max(sum [counter],biggest);
    }}
     while (counter--)
    {
        if (sum[counter]==biggest)
            number=counter;
    }
    cout << names[number];

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,biggest=-10000,number=0;
    cin >>n;
    string names [50];
    int hacksp[50],hacksm[50],a[50],b[50],c[50],d[50],e[50],sum[50];
    int counter;
    for(counter=0;counter<n;counter++)
    {
        cin >>names[counter]>>hacksp[counter]>>hacksm[counter]>>a[counter]>>b[counter]
            >>c[counter]>>d[counter]>>e[counter];
        sum [counter] =hacksp[counter]*100-hacksm[counter]*50+a[counter]+b[counter]
        +c[counter]+d[counter]+e[counter];
        biggest = max(sum [counter],biggest);
    }
     while (counter--)
    {
        if (sum[counter]==biggest)
            number=counter;
    }
    cout << names[number];

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,biggest=0,number=0;
    cin >>n;
    string names [50];
    int hacksp[50],hacksm[50],a[50],b[50],c[50],d[50],e[50],sum[50];
    int counter;
    for(counter=0;counter<n;counter++)
    {
        cin >>names[counter]>>hacksp[counter]>>hacksm[counter]>>a[counter]>>b[counter]
            >>c[counter]>>d[counter]>>e[counter];
        sum [counter] =hacksp[counter]*100-hacksm[counter]*50+a[counter]+b[counter]
        +c[counter]+d[counter]+e[counter];
        int positive=0;
        for (int a=0;a<n;a++)
        {
            if (sum[a]<0)
                positive++;

        if (positive==n)
        {
            for (int b=0;b<n;b++)
            {
                sum [b]=sum[b]*-1;
            }
            biggest = min(sum [counter],biggest);
        }
        else biggest = max(sum [counter],biggest);
    }}
     while (counter--)
    {
        if (sum[counter]==biggest)
            number=counter;
    }
    cout << names[number];

    return 0;
}


#include<stdio.h>
#include<string.h>

int main(void)
{
    int n,a,b,c,d,e,plus,minus,i, max = 0,points,j;
    char name[20],ans[20];
    scanf("%d", &n);
    for ( i = 0; i < n; i++){
        scanf("%s", name);
        scanf("%d%d%d%d%d%d%d", &plus, & minus, &a, &b, &c, &d, &e);
        points = 100*plus - 50*minus + a + b + c + d + e;
        if ( points > max){
           strcpy(ans, name);
           max = points;
        }
    }
    printf("%s\n", ans);

    return 0;

}


#include <iostream>
using namespace std;
int main()
{
    int max = 0,n,plus,minus,a,b,c,d,e,i,points;
    string name,ans;
    cin >> n;

    for (i = 0; i < n; i++){

        cin >> name >> plus >> minus >> a >> b >> c >> d >>e;
        points = plus*100 - minus*50 + a + b + c + d + e;
        if (points > max){
          max = points;
          ans = name;
        }
    }
    cout << ans;
    return 0;
}


#include<iostream>
using namespace std;

int main(void)
{
    int n,a,b,c,d,e,plus,minus,i, max = 0,points,j;
    string name, ans;
    cin >> n;
    for ( i = 0; i < n; i++){
        cin >> name;
        scanf("%d%d%d%d%d%d%d", &plus, & minus, &a, &b, &c, &d, &e);
        points = 100*plus - 50*minus + a + b + c + d + e;
        if ( points > max){
           ans = name;
           max = points;
        }
    }
    cout << ans;

    return 0;

}


#include <iostream>
using namespace std;
int main()
{
    int max = -1000000,n,plus,minus,a,b,c,d,e,i,points;
    string name,ans;
    cin >> n;

    for (i = 0; i < n; i++){

        cin >> name >> plus >> minus >> a >> b >> c >> d >>e;
        points = plus*100 - minus*50 + a + b + c + d + e;
        if (points > max){
          max = points;
          ans = name;
        }
    }
    cout << ans;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main ( ) {
        vector < pair < string, int > > myv;
        int n;
        pair < string, int > myp;
        string handle;
        int plus, minus, a, b, c, d, e, i, max_points, ans, points;
        while ( cin >> n ) {
                max_points = 0, ans = 0, myv.clear ( );
                for ( i = 0; i < n; ++i ) {
                        cin >> handle >> plus >> minus >> a >> b >> c >> d >> e;
                        points = plus * 100 - minus * 50 + a + b + c + d + e;
                        if ( max_points < points ) {
                                max_points = points;
                                ans = i;
                        }
                        myp = make_pair ( handle, points );
                        myv.push_back ( myp );
                }
                cout << myv[ans].first << endl;
        }
}


#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main ( ) {
        vector < pair < string, long long > > myv;
        pair < string, long long > myp;
        string handle;
        int n, plus, minus, a, b, c, d, e, i, ans;
        long long points, max_points;
        while ( cin >> n ) {
                max_points = 0, ans = 0, myv.clear ( );
                for ( i = 0; i < n; ++i ) {
                        cin >> handle >> plus >> minus >> a >> b >> c >> d >> e;
                        points = plus * 100 - minus * 50 + a + b + c + d + e;
                        if ( max_points < points ) {
                                max_points = points;
                                ans = i;
                        }
                        myp = make_pair ( handle, points );
                        myv.push_back ( myp );
                }
                /*for ( i = 0; i < n; ++i ) {
                        cout << myv[i].first << "       " << myv[i].second << endl;
                }*/
                cout << myv[ans].first << endl;
        }
}


#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main ( ) {
        vector < pair < string, int > > myv;
        int n;
        pair < string, int > myp;
        string handle;
        int plus, minus, a, b, c, d, e, i, max_points, ans, points;
        while ( cin >> n ) {
                max_points = 0, ans = 0, myv.clear ( );
                for ( i = 0; i < n; ++i ) {
                        cin >> handle >> plus >> minus >> a >> b >> c >> d >> e;
                        points = ( plus - minus ) * 50 + a + b + c + d + e;
                        if ( max_points < points ) {
                                max_points = points;
                                ans = i;
                        }
                        myp = make_pair ( handle, points );
                        myv.push_back ( myp );
                }
                cout << myv[ans].first << endl;
        }
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main ( ) {
        vector < pair < int, string > > myv;
        string handle;
        int n, plus, minus, a, b, c, d, e, i, points;
        while ( cin >> n ) {
                myv.clear ( );
                for ( i = 0; i < n; ++i ) {
                        cin >> handle >> plus >> minus >> a >> b >> c >> d >> e;
                        points = plus * 100 - minus * 50 + a + b + c + d + e;
                        myv.push_back ( make_pair ( points, handle ) );

                }
                sort ( myv.rbegin ( ), myv.rend ( ) );
                cout << myv[0].second << endl;
        }
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <typeinfo>
#include <set>
#include <cctype>
#include <locale>
#include <utility>

using namespace std;

long long in(){
    long long a;
    scanf("%llu",&a);
    return a;
}
int ou(int a){
    printf("%d",a);
    return 0;
}
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
struct ed{
    int a, b, cost;
};
struct names{
    string name;
    int reyt;

};

const long long INF = 1000000;

vector <int> tobin(long long a){
    vector <int> A;
    while(a!=0){
        A.push_back(a%2);
        a/=2;
    }

    return A;
}

int main(){
//    freopen("in.txt","r",stdin);
//        freopen("out.txt","w",stdout);

    int n=in();
    string nick,mnick;
    int maxx=0,sum=0;
    cin>>nick;
    mnick=nick;
    for(int i=0;i<n;i++){

        sum=0;
        sum+=in()*100;
        sum-=in()*50;
        sum+=in()+in()+in()+in()+in();
        if(sum>maxx){
            maxx=sum;
            mnick=nick;

        }
        cin>>nick;
    }
    cout<<mnick;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <typeinfo>
#include <set>
#include <cctype>
#include <locale>
#include <utility>

using namespace std;

long long in(){
    long long a;
    scanf("%llu",&a);
    return a;
}
int ou(int a){
    printf("%d",a);
    return 0;
}
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
struct ed{
    int a, b, cost;
};
struct names{
    string name;
    int reyt;

};

const long long INF = 1000000;

vector <int> tobin(long long a){
    vector <int> A;
    while(a!=0){
        A.push_back(a%2);
        a/=2;
    }

    return A;
}

int main(){
//    freopen("in.txt","r",stdin);
//        freopen("out.txt","w",stdout);

    int n=in();
    string nick,mnick;
    int maxx=0,sum=0;
    for(int i=0;i<n;i++){
        cin>>nick;
        sum=0;
        sum+=in()*100;
        sum-=in()*50;
        sum+=in()+in()+in()+in()+in();
        if(sum>maxx){
            maxx=sum;
            mnick=nick;

        }
    }
    cout<<mnick;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <typeinfo>
#include <set>
#include <cctype>
#include <locale>
#include <utility>

using namespace std;

long long in(){
    long long a;
    scanf("%llu",&a);
    return a;
}
int ou(int a){
    printf("%d",a);
    return 0;
}
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
struct ed{
    int a, b, cost;
};
struct names{
    string name;
    int reyt;

};

const long long INF = 1000000;

vector <int> tobin(long long a){
    vector <int> A;
    while(a!=0){
        A.push_back(a%2);
        a/=2;
    }

    return A;
}

int main(){
//    freopen("in.txt","r",stdin);
//        freopen("out.txt","w",stdout);

    int n=in();
    string nick,mnick;
    int maxx=0,sum=0;
    cin>>nick;
    sum=0;
        sum+=in()*100;
        sum-=in()*50;
        sum+=in()+in()+in()+in()+in();
        if(sum>maxx){
            maxx=sum;
            mnick=nick;

        }
    for(int i=1;i<n;i++){
        cin>>nick;
        sum=0;
        sum+=in()*100;
        sum-=in()*50;
        sum+=in()+in()+in()+in()+in();
        if(sum>maxx){
            maxx=sum;
            mnick=nick;

        }

    }
    cout<<mnick;

    return 0;
}


    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <deque>
    #include <algorithm>
    #include <typeinfo>
    #include <set>
    #include <cctype>
    #include <locale>
    #include <utility>

    using namespace std;

    long long in(){
        long long a;
        scanf("%llu",&a);
        return a;
    }
    int ou(int a){
        printf("%d",a);
        return 0;
    }
    int gcd(int a,int b){
        return b?gcd(b,a%b):a;
    }
    int lcm(int a,int b){
        return a/gcd(a,b)*b;
    }
    struct ed{
        int a, b, cost;
    };
    struct names{
        string name;
        int reyt;

    };

    const long long INF = 1000000;

    vector <int> tobin(long long a){
        vector <int> A;
        while(a!=0){
            A.push_back(a%2);
            a/=2;
        }

        return A;
    }

    int main(){
    //    freopen("in.txt","r",stdin);
    //        freopen("out.txt","w",stdout);

        int n=in();
        string nick,mnick;
        int maxx=0,sum=0;
        cin>>nick;
        mnick=nick;
        sum=0;
            sum+=in()*100;
            sum-=in()*50;
            sum+=in()+in()+in()+in()+in();
            if(sum>maxx){
                maxx=sum;
                mnick=nick;

            }
            maxx=sum;
        for(int i=1;i<n;i++){
            cin>>nick;
            sum=0;
            sum+=in()*100;
            sum-=in()*50;
            sum+=in()+in()+in()+in()+in();
            if(sum>maxx){
                maxx=sum;
                mnick=nick;

            }

        }
        cout<<mnick;

        return 0;
    }


#include <algorithm>
#include <iostream>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

        int n;

cin>>n;
string s[100];
int a,b,c,d,e,x,y;
int ind=0;
int maxi = -99999;
for(int i=1;i<=n;i++){
cin>>s[i]>>x>>y>>a>>b>>c>>d>>e;
if(x*100-y*50+a+b+c+d+e > maxi){maxi=x*100-y*50+a+b+c+d+e; ind=i;}

}

cout<<s[ind];

return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

int n,a[100],b[100],c[100],d[100],e[100],p[120],m[100];
string s[100];

cin>>n;
int sum[100];
int maxi = 0,ind = -1;
for(int i=1;i<=n;i++){
cin>>s[i]>>p[i]>>m[i]>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
sum[i]=p[i]*50-m[i]*100+a[i]+b[i]+c[i]+d[i]+e[i];
}
for(int i=1;i<=n;i++){
if(sum[i] > maxi){maxi=sum[i];ind=i;}
}

cout<<s[ind];

return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

        int n;

cin>>n;
string s[100];
int a,b,c,d,e,x,y;
int ind=0;
int maxi = 0;
for(int i=1;i<=n;i++){
cin>>s[i]>>x>>y>>a>>b>>c>>d>>e;
if(x*100-y*50+a+b+c+d+e > maxi){maxi=x*100-y*50+a+b+c+d+e; ind=i;}

}

cout<<s[ind];

return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

int n,a[100],b[100],c[100],d[100],e[100],p[120],m[100];
string s[100];

cin>>n;
int sum[100];
int maxi = 0,ind = -1;
for(int i=1;i<=n;i++){
cin>>s[i]>>p[i]>>m[i]>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
sum[i]=p[i]*50-m[i]*100+a[i]+b[i]+c[i]+d[i]+e[i];
}
for(int i=1;i<=n;i++){
if(sum[i] > maxi){maxi=sum[i];ind=i;}
}

return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
char bb[100][100];
int main()
{
    int n,one;
    int max = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb[i];
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            one = i;
        }
    }
    cout<<bb[one]<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
char bb[100][100];
int main()
{
    int n,one;
    int max = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb[i];
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            one = i;
        }
    }

    cout<<bb[one]<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
string cc,bb;
int main()
{
    int n,one;
    int max = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb;
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            cc = bb;

        }
    }

    cout<<cc<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
char bb[100][1000];
int main()
{
    int n,one;
    int max = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb[i];
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            one = i;
        }
    }

    cout<<bb[one]<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
int main()
{
    int n,one;
    string cc,bb;
    int max = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb;
        cc = bb;
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            cc = bb;
        }
    }

    cout<<cc<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
char bb[100][100];
int main()
{
    int n,one = 1;
    int max = -1000000;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb[i];
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            one = i;
        }
    }
    cout<<bb[one]<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
char bb[100][100];
int main()
{
    int n,one;
    int max = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        char cc;
        cin>>bb[i];
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            one = i;
        }
    }
    cout<<bb[one]<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
int main()
{
    int n,one;
    string cc,bb;
    int max = 0;
    int tag = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb;
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            cc = bb;
            tag = 1;
        }
    }
    if( tag == 1)
        cout<<cc<<endl;
    else
        cout<<bb<<endl;
    return 0;
}


/*
 * Author: luyanan
 * Created Time:  2011/4/15 23:10:43
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(v) ((int)(v).size())
char bb[100][100];
int main()
{
    int n,one = 1;
    int max = 0;
    cin>>n;
    for( int i = 1; i <= n; i++)
    {
        int p = 0,h = 0,a = 0,b = 0,c = 0,d = 0,e = 0;
        int sum = 0;
        cin>>bb[i];
        cin>>p>>h>>a>>b>>c>>d>>e;
        sum =  (p * 100 - h * 50 + a + b + c + d + e);
        if( sum > max)
        {
            max = sum;
            one = i;
        }
    }
    cout<<bb[one]<<endl;
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int max,k,n,x1,x2,x3,x4,x5,x6,x7;
    string s,str;
    char c;

    cin >>n;
    max=-5000;
    k=0;
    for (int i=0;i<n;i++)
    {
        cin>> s;
        while (true)
              {
                 c=getchar();
                 if (c==' ') break;
                    else s+=c;
              }

        cin >> x1>>x2>>x3>>x4>>x5>>x6>>x7;
        k=x1*100-x2*50+x2+x3+x4+x5+x6+x7;
        if (k>max) {max=k;str=s;};

    }
    cout<<str;
    system("PAUSE");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int max,k,n,x1,x2,x3,x4,x5,x6,x7;
    string s,str;
    char c;

    cin >>n;
    max=-1;
    k=0;
    for (int i=0;i<n;i++)
    {
        cin>> s;
        while (true)
              {
                 c=getchar();
                 if (c==' ') break;
                    else s+=c;
              }

        cin >> x1>>x2>>x3>>x4>>x5>>x6>>x7;
        k=x1*100-x2*50+x2+x3+x4+x5+x6+x7;
        if (k>max) {max=k;str=s;};

    }
    cout<<str;
    //system("PAUSE");
    return 0;
}


#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int max,k,n,x1,x2,x3,x4,x5,x6,x7;
    string s,str;
    char c;

    cin >>n;
    max=0;
    k=0;
    for (int i=0;i<n;i++)
    {
        cin>> s;
        while (true)
              {
                 c=getchar();
                 if (c==' ') break;
                    else s+=c;
              }

        cin >> x1>>x2>>x3>>x4>>x5>>x6>>x7;
        k=x1*100-x2*50+x2+x3+x4+x5+x6+x7;
        if (k>max) {max=k;str=s;};

    }
    cout<<str;
    //system("PAUSE");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int max,k,n,x1,x2,x3,x4,x5,x6,x7;
    string s,str;
    char c;

    cin >>n;
    max=0;
    k=0;
    for (int i=0;i<n;i++)
    {
        cin>> s;
        while (true)
              {
                 c=getchar();
                 if (c==' ') break;
                    else s+=c;
              }

        cin >> x1>>x2>>x3>>x4>>x5>>x6>>x7;
        k=x1*100-x2*50+x2+x3+x4+x5+x6+x7;
        if (k>max) {max=k;str=s;};

    }
    cout<<str;
    //system("PAUSE");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int max,k,n,x1,x2,x3,x4,x5,x6,x7;
    string s,str;
    char c;

    cin >>n;
    max=-5000;
    k=0;
    for (int i=0;i<n;i++)
    {
        cin>> s;
        while (true)
              {
                 c=getchar();
                 if (c==' ') break;
                    else s+=c;
              }

        cin >> x1>>x2>>x3>>x4>>x5>>x6>>x7;
        k=x1*100-x2*50+x2+x3+x4+x5+x6+x7;
        if (k>max) {max=k;str=s;};

    }
    cout<<str;
    //system("PAUSE");
    return 0;
}


#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<conio.h>
using namespace std;
int a[51],b,c,d,e,f,T,F,n,i,m;
int main(){
string s[51];
cin>>n;
for(i=0;i<n;i++){
                 cin>>s[i]>>T>>f>>b>>c>>d>>e>>f;
                 a[i]+=T*100-F*50+b+c+d+e+f;
                 if(a[m]<a[i])m=i;
                     }
cout<<s[m]<<endl;
    return 0;
}


#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<conio.h>
using namespace std;
int a[51],b,c,d,e,f,T,F,n,i,m;
int main(){
string s[51];
scanf("%d",&n);
for(i=0;i<n;i++){
                 cin>>s[i];
                 scanf("%d%d%d%d%d%d%d",&T,&F,&b,&c,&d,&e,&f);
                 a[i]+=T*100-F*50+b+c+d+e+f;
                 if(a[m]<a[i])m=i;
                     }
cout<<s[m]<<endl;
    return 0;
}


#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<conio.h>
using namespace std;
int a[51]={0},b,c,d,e,f,T,F,n,i,m=0;
int main(){
string s[51];
cin>>n;
for(i=0;i<n;i++){
                 cin>>s[i]>>T>>F>>b>>c>>d>>e>>f;
                 a[i]+=T*100-F*50+b+c+d+e+f;
                 if(a[m]<a[i])m=i;
                     }
cout<<s[m]<<endl;
    return 0;
}


#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
using namespace std;
int a[51],b,c,d,e,f,T,F,n,i,m;
int main(){
string s[51];
scanf("%d",&n);
for(i=0;i<n;i++){
                 cin>>s[i];
                 scanf("%d%d%d%d%d%d%d",&T,&F,&b,&c,&d,&e,&f);
                 a[i]+=T*100-F*50+b+c+d+e+f;
                 if(a[m]<a[i])m=i;
                     }
cout<<s[m]<<endl;
    return 0;
}


#include <string.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define LL long long
#define VI vector <int>
#define VS vector <string>
#define VD vector <double>
#define PB push_back
#define PP pop_back
#define clr(x) memset(x,0,sizeof(x))
#define debug() printf("Here take a debug!\n");
//const double PI=acos(-1.0);

int main()
{
       // freopen("d://in.txt","r",stdin);
        int n;
        scanf("%d\n",&n);
        int tot=-2501;
        char win[101];
        int lenth=0;
        for(int i=0;i<n;i++){
            char cc[101];
            int one,two,a,b,c,d,e;
            scanf("%s%d%d%d%d%d%d",cc,&one,&two,&a,&b,&c,&d,&e);
            int temp=one*100-two*50+a+b+c+d+e;
            if(temp>tot){
                tot=temp;
                lenth=strlen(cc);
                for(int k=0;k<lenth;k++)
                    win[k]=cc[k];
            }
        }
        for(int i=0;i<lenth;i++)
            printf("%c",win[i]);
        return 0;
}


#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define LL long long
#define VI vector <int>
#define VS vector <string>
#define VD vector <double>
#define PB push_back
#define PP pop_back
#define clr(x) memset(x,0,sizeof(x))
#define debug() printf("Here take a debug!\n");
//const double PI=acos(-1.0);

int main()
{

        int n;
        scanf("%d\n",&n);
        int maxIndex=0;
        int tot=0;
        char win[101];
        for(int i=0;i<n;i++){
            char cc[101];
            int one,two,a,b,c,d,e;
            scanf("%s%d%d%d%d%d%d",cc,&one,&two,&a,&b,&c,&d,&e);
            int temp=one*100-two*50+a+b+c+d+e;
            if(temp>tot){
                tot=temp;
                int lenth=strlen(cc);
                for(int k=0;k<lenth;k++)
                    win[k]=cc[k];
            }
        }
        int lenth=strlen(win);
        for(int i=0;i<lenth;i++)
            printf("%c",win[i]);
        printf("\n");
        return 0;
}


#include <string.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define LL long long
#define VI vector <int>
#define VS vector <string>
#define VD vector <double>
#define PB push_back
#define PP pop_back
#define clr(x) memset(x,0,sizeof(x))
#define debug() printf("Here take a debug!\n");
//const double PI=acos(-1.0);

int main()
{
       // freopen("d://in.txt","r",stdin);
        int n;
        scanf("%d\n",&n);
        int tot=-2501;
        char win[21];
        int lenth=0;
        for(int i=0;i<n;i++){
            char cc[21];
            int one,two,a,b,c,d,e;
            scanf("%s%d%d%d%d%d%d%d",cc,&one,&two,&a,&b,&c,&d,&e);
            int temp=one*100-two*50+a+b+c+d+e;
            int len=strlen(cc);
            if(temp>tot){
                tot=temp;
                lenth=strlen(cc);
                for(int k=0;k<lenth;k++)
                    win[k]=cc[k];
            }
        }
        for(int i=0;i<lenth;i++)
            printf("%c",win[i]);
        return 0;
}


#include <string.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define LL long long
#define VI vector <int>
#define VS vector <string>
#define VD vector <double>
#define PB push_back
#define PP pop_back
#define clr(x) memset(x,0,sizeof(x))
#define debug() printf("Here take a debug!\n");
//const double PI=acos(-1.0);

int main()
{
        //freopen("d://in.txt","r",stdin);
        int n;
        scanf("%d\n",&n);
        int maxIndex=0;
        int tot=0;
        char win[101];
        for(int i=0;i<n;i++){
            char cc[101];
            int one,two,a,b,c,d,e;
            scanf("%s%d%d%d%d%d%d",cc,&one,&two,&a,&b,&c,&d,&e);
            int temp=one*100-two*50+a+b+c+d+e;
            if(temp>tot){
                tot=temp;
                int lenth=strlen(cc);
                for(int k=0;k<lenth;k++)
                    win[k]=cc[k];
            }
        }
        int lenth=strlen(win);
        for(int i=0;i<lenth;i++)
            printf("%c",win[i]);
        printf("\n");
        return 0;
}


#include <string.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define LL long long
#define VI vector <int>
#define VS vector <string>
#define VD vector <double>
#define PB push_back
#define PP pop_back
#define clr(x) memset(x,0,sizeof(x))
#define debug() printf("Here take a debug!\n");
//const double PI=acos(-1.0);

int main()
{
       // freopen("d://in.txt","r",stdin);
        int n;
        scanf("%d\n",&n);
        int maxIndex=0;
        int tot=0;
        char win[101];
        int lenth=0;
        for(int i=0;i<n;i++){
            char cc[101];
            int one,two,a,b,c,d,e;
            scanf("%s%d%d%d%d%d%d",cc,&one,&two,&a,&b,&c,&d,&e);
            int temp=one*100-two*50+a+b+c+d+e;
            if(temp>tot){
                tot=temp;
                lenth=strlen(cc);
                for(int k=0;k<lenth;k++)
                    win[k]=cc[k];
            }
        }
        for(int i=0;i<lenth;i++)
            printf("%c",win[i]);
        return 0;
}


/*
 * File:   main.cpp
 * Author: pol
 *
 * Created on April 15, 2011, 6:56 PM
 */

#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

/*
 *
 */
int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector< pair<string, int> > g;
    for(int i = 0; i<n; i++){
        string s;
        cin >> s;
        int plus, minus;
        cin >> plus >> minus;
        int a, b, c, d, e;
        cin >> a >> b >> c >> d >> e;
        int answ = plus*100 - 50*minus + a + b + c + d + e;
        g.push_back(make_pair(s, answ));
        cout << answ << endl;
    }
    sort(g.begin(), g.end());
    cout << g[g.size()-1].first << endl;
    return 0;
}


/*
 * File:   main.cpp
 * Author: pol
 *
 * Created on April 15, 2011, 6:56 PM
 */

#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

/*
 *
 */
int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector< pair<int, string> > g;
    for(int i = 0; i<n; i++){
        string s;
        cin >> s;
        int plus, minus;
        cin >> plus >> minus;
        int a, b, c, d, e;
        cin >> a >> b >> c >> d >> e;
        int answ = plus*100 - 50*minus + a + b + c + d + e;
        g.push_back(make_pair(answ, s));
    }
    sort(g.begin(), g.end());
    cout << g.back().second << endl;
    return 0;
}


/*
 * File:   main.cpp
 * Author: pol
 *
 * Created on April 15, 2011, 6:56 PM
 */

#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

/*
 *
 */
int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector< pair<int, string> > g;
    for(int i = 0; i<n; i++){
        string s;
        cin >> s;
        int plus, minus;
        cin >> plus >> minus;
        int a, b, c, d, e;
        cin >> a >> b >> c >> d >> e;
        int answ = plus*100 - 50*minus + a + b + c + d + e;
        g.push_back(make_pair(answ, s));
        cout << answ << endl;
    }
    sort(g.begin(), g.end());
    cout << g.back().second << endl;
    return 0;
}


/*
 * File:   main.cpp
 * Author: pol
 *
 * Created on April 15, 2011, 6:56 PM
 */

#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

/*
 *
 */
int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector< pair<string, int> > g;
    for(int i = 0; i<n; i++){
        string s;
        cin >> s;
        int plus, minus;
        cin >> plus >> minus;
        int a, b, c, d, e;
        cin >> a >> b >> c >> d >> e;
        int answ = plus*100 - 50*minus + a + b + c + d + e;
        g.push_back(make_pair(s, answ));
    }
    sort(g.begin(), g.end());
    cout << g.back().first << endl;
    return 0;
}


/*
 * File:   main.cpp
 * Author: pol
 *
 * Created on April 15, 2011, 6:56 PM
 */

#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

/*
 *
 */
int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector< pair<string, int> > g;
    for(int i = 0; i<n; i++){
        string s;
        cin >> s;
        int plus, minus;
        cin >> plus >> minus;
        int a, b, c, d, e;
        cin >> a >> b >> c >> d >> e;
        int answ = plus*100 - 50*minus + a + b + c + d + e;
        g.push_back(make_pair(s, answ));
    }
    sort(g.begin(), g.end());
    cout << g[g.size()-1].first << endl;
    return 0;
}


/*
 * File:   main.cpp
 * Author: pol
 *
 * Created on April 15, 2011, 6:56 PM
 */

#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

/*
 *
 */
int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector< pair<char *, int> > g;
    for(int i = 0; i<n; i++){
//        string s;
        char s[100];
        scanf("%s", &s);
//        cin >> s;
        int plus, minus;
        cin >> plus >> minus;
        int a, b, c, d, e;
        cin >> a >> b >> c >> d >> e;
        int answ = plus*100 - 50*minus + a + b + c + d + e;
        g.push_back(make_pair(s, answ));
    }
    sort(g.begin(), g.end());
    cout << g[g.size()-1].first << endl;
    return 0;
}


#include<bits/stdc++.h>
#include<string>

using namespace std;
int main()
{
    int n,p,m,a,b,c,d,e,x,maxi=-1000;
    string s;
    map<string,int>mp;
    map<string,int>::iterator it;
    cin>>n;
    for(int i=0; i<n; i++)
    {

        cin>>s>>p>>m>>a>>b>>c>>d>>e;
        x=(p*100)+(m*(-50))+a+b+c+d+e;
        mp[s]=x;

    }
    for(it=mp.begin(); it!=mp.end(); it++)
    {
        if(it->second>maxi)
        {
            maxi=it->second;
        }
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        if(it->second==maxi)
        {
            cout<<it->first<<endl;
            break;
        }
    }
}


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 linf = 2e17;
const int inf = 2e9;
i64 n,k,a[200020],t,bit[200020],ans,b[200020];
pi64 sum[200020];

int f(int i) {
  int f = 0;
  while (i > 0)
    f += bit[i], i -= (i & (-i));
  return f;
}

void add(int i) {
  while (i <= n)
    bit[i]++, i += (i & (-i));
}

int binary(i64 x) {
  int ll = 1,rr = n,mid = (1 + n)>>1;
  while(ll != mid and rr != mid) {
    mid = (ll + rr)>>1;
    if(sum[mid].fi >= x) rr = mid - 1;
    else ll = mid;
  }
  for(int i = rr;i >= ll;--i) if(sum[i].fi < x) return i;
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
/*--------------------------------------------------END--------------------------------------------------*/
  scanf("%I64d %I64d", &n, &k);
  rep1(i,n) scanf("%I64d",a + i);
  rep1(i,n) sum[i] = make_pair(a[i] + sum[i - 1].fi,i);
  sort(sum + 1,sum + 1 + n);
  rep1(i,n) b[sum[i].se] = i;
  i64 xx = 0;
  rep1(i,n) {
    i64 yy = xx + k;
    int cc = binary(yy);
    xx += a[i];
    if(cc) ans += max(0,cc - f(cc));
    if(i <= n) add(b[i]);
  }
  printf("%I64d\n", ans);;
}


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 linf = 2e17;
const int inf = 2e9;
i64 n,k,a[231234],t,bit[231234],ans,b[231234];
pi64 sum[231234];

int f(int i) {
  int f = 0;
  while (i > 0)
    f += bit[i], i -= (i & (-i));
  return f;
}

void add(int i) {
  while (i <= n)
    bit[i]++, i += (i & (-i));
}

int binary(int x) {
  int ll = 1,rr = n,mid = (1 + n)/2LL;
  while(ll != mid and rr != mid) {
    mid = (ll + rr)/2LL;
    if(sum[mid].fi >= x) rr = mid;
    else ll = mid;
  }
  for(int i = rr;i >= ll;--i) if(sum[i].fi < x) return i;
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
/*--------------------------------------------------END--------------------------------------------------*/
  scanf("%I64d %I64d", &n, &k);
  rep1(i,n) scanf("%I64d",a + i);
  rep1(i,n) sum[i] = make_pair(a[i] + sum[i - 1].fi,i);
  sort(sum + 1,sum + 1 + n);
  rep1(i,n) b[sum[i].se] = i;
  i64 xx = 0;
  rep1(i,n + 1) {
    i64 yy = xx + k;
    int cc = binary(yy);
    xx += a[i];
    ans += max(0,cc - f(cc));
    if(i <= n) add(b[i]);
  }
  cout << ans;
}


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 linf = 2e17;
const int inf = 2e9;
i64 n,k,a[231234],t,bit[231234],ans,b[231234];
pi64 sum[231234];

int f(int i) {
  int f = 0;
  while (i > 0)
    f += bit[i], i -= (i & (-i));
  return f;
}

void add(int i) {
  while (i <= n)
    bit[i]++, i += (i & (-i));
}

int binary(int x) {
  int ll = 1,rr = n,mid = (1 + n)/2LL;
  while(ll != mid and rr != mid) {
    mid = (ll + rr)/2LL;
    if(sum[mid].fi >= x) rr = mid;
    else ll = mid;
  }
  for(int i = rr;i >= ll;--i) if(sum[i].fi < x) return i;
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
/*--------------------------------------------------END--------------------------------------------------*/
  cin >> n >> k;
  rep1(i,n) scanf("%I64d",a + i)
  rep1(i,n) sum[i] = make_pair(a[i] + sum[i - 1].fi,i);
  sort(sum + 1,sum + 1 + n);
  rep1(i,n) b[sum[i].se] = i;
  i64 xx = 0;
  rep1(i,n + 1) {
    i64 yy = xx + k;
    int cc = binary(yy);
    xx += a[i];
    ans += max(0,cc - f(cc));
    if(i <= n) add(b[i]);
  }
  cout << ans;
}


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 linf = 2e17;
const int inf = 2e9;
i64 n,k,a[231234],t,bit[231234],ans,b[231234];
pi64 sum[231234];

int f(int i) {
  int f = 0;
  while (i > 0)
    f += bit[i], i -= (i & (-i));
  return f;
}

void add(int i) {
  while (i <= n)
    bit[i]++, i += (i & (-i));
}

int binary(long long x) {
  int ll = 1,rr = n,mid = (1 + n)/2LL;
  while(ll != mid and rr != mid) {
    mid = (ll + rr)/2LL;
    if(sum[mid].fi >= x) rr = mid;
    else ll = mid;
  }
  for(int i = rr;i >= ll;--i) if(sum[i].fi < x) return i;
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
/*--------------------------------------------------END--------------------------------------------------*/
  scanf("%I64d %I64d", &n, &k);
  rep1(i,n) scanf("%I64d",a + i);
  rep1(i,n) sum[i] = make_pair(a[i] + sum[i - 1].fi,i);
  sort(sum + 1,sum + 1 + n);
  rep1(i,n) b[sum[i].se] = i;
  i64 xx = 0;
  rep1(i,n) {
    i64 yy = xx + k;
    int cc = binary(yy);
    xx += a[i];
    if(cc) ans += max(0,cc - f(cc));
    if(i <= n) add(b[i]);
  }
  cout << ans;
}


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 linf = 2e17;
const int inf = 2e9;
i64 n,k,a[231234],t,bit[231234],ans,b[231234];
pi64 sum[231234];

int f(int i) {
  int f = 0;
  while (i > 0)
    f += bit[i], i -= (i & (-i));
  return f;
}

void add(int i) {
  while (i <= n)
    bit[i]++, i += (i & (-i));
}

int binary(i64 x) {
  int ll = 1,rr = n,mid = (1 + n)/2LL;
  while(ll != mid and rr != mid) {
    if(sum[mid].fi >= x) rr = mid;
    else ll = mid;
    mid = (ll + rr)/2LL;
  }
  for(int i = rr;i >= ll;--i) if(sum[i].fi < x) return i;
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
/*--------------------------------------------------END--------------------------------------------------*/
  cin >> n >> k;
  rep1(i,n) cin >> a[i];
  rep1(i,n) sum[i] = make_pair(a[i] + sum[i - 1].fi,i);
  sort(sum + 1,sum + 1 + n);
  rep1(i,n) b[sum[i].se] = i;
  i64 xx = 0;
  rep1(i,n + 1) {
    i64 yy = xx + k;
    int cc = binary(yy);
    xx += a[i];
    ans += max(0,cc - f(cc));
    if(i <= n) add(b[i]);
  }
  cout << ans;
}


//-----------------
//author: d0uch3b4g
//-----------------

#include "bits/stdc++.h"
#define SIZE          200005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){

        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}

bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

vector<LL> tree[4*SIZE];
vector<LL> v;

void build(int node,int l,int r){
	if(l==r) {
		tree[node].push_back(v[l]);
		return;
	}
	int mid=(l+r)/2;
	int left=node*2,right=node*2+1;
	build(left,l,mid);
	build(right,mid+1,r);
	merge(tree[left].begin(),tree[left].end(),tree[right].begin(),tree[right].end(),back_inserter(tree[node]));
}

LL query(int node,int l,int r,int L1,int R,LL val){
	if(l>R||r<L1) return 0;
	else if(l>=L1 and r<=R){
		return lower_bound(tree[node].begin(),tree[node].end(),val)-tree[node].begin();
	}
	int mid=(l+r)/2;
	int lef=node*2,rig=node*2+1;
	int f=query(lef,l,mid,L1,R,val);
	int s=query(rig,mid+1,r,L1,R,val);
	return f+s;
}
int main(){
	FAST;
	//freopen("test.in","r",stdin);
	LL a,b;
	cin>>a>>b;
	v.push_back(0);
	LL ar;
	for(LL i=1;i<=a;i++){
		cin>>ar;
		v.push_back(ar+v[v.size()-1]);
	}
	build(1,1,a);
	LL tot=0;
	for(LL i=1;i<=a;i++){
		LL res=query(1,1,a,i,a,v[i-1]+b);
		//cout<<res<<endl;
		tot+=res;
	}
	cout<<tot<<endl;
	cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


//-----------------
//author: d0uch3b4g
//-----------------

#include "bits/stdc++.h"
#define SIZE          200005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){

        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}

bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

vector<int> tree[4*SIZE];
vector<LL> v;

void build(int node,int l,int r){
	if(l==r) {
		tree[node].push_back(v[l]);
		return;
	}
	int mid=(l+r)/2;
	int left=node*2,right=node*2+1;
	build(left,l,mid);
	build(right,mid+1,r);
	merge(tree[left].begin(),tree[left].end(),tree[right].begin(),tree[right].end(),back_inserter(tree[node]));
}

LL query(int node,int l,int r,int L1,int R,LL val){
	if(l>R||r<L1) return 0;
	else if(l>=L1 and r<=R){
		return lower_bound(tree[node].begin(),tree[node].end(),val)-tree[node].begin();
	}
	int mid=(l+r)/2;
	int lef=node*2,rig=node*2+1;
	int f=query(lef,l,mid,L1,R,val);
	int s=query(rig,mid+1,r,L1,R,val);
	return f+s;
}
int main(){
	FAST;
	//freopen("test.in","r",stdin);
	LL a,b;
	cin>>a>>b;
	v.push_back(0);
	LL ar;
	for(LL i=1;i<=a;i++){
		cin>>ar;
		v.push_back(ar+v[v.size()-1]);
	}
	build(1,1,a);
	LL tot=0;
	for(LL i=1;i<=a;i++){
		LL res=query(1,1,a,i,a,v[i-1]+b);
		//cout<<res<<endl;
		tot+=res;
	}
	cout<<tot<<endl;
	cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


//-----------------
//author: d0uch3b4g
//-----------------

#include "bits/stdc++.h"
#define SIZE          100005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){

        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}

bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

vector<int> tree[4*SIZE];
vector<LL> v;

void build(int node,int l,int r){
	if(l==r) {
		tree[node].push_back(v[l]);
		return;
	}
	int mid=(l+r)/2;
	int left=node*2,right=node*2+1;
	build(left,l,mid);
	build(right,mid+1,r);
	merge(tree[left].begin(),tree[left].end(),tree[right].begin(),tree[right].end(),back_inserter(tree[node]));
}

LL query(int node,int l,int r,int L1,int R,LL val){
	if(l>R||r<L1) return 0;
	else if(l>=L1 and r<=R){
		return lower_bound(tree[node].begin(),tree[node].end(),val)-tree[node].begin();
	}
	int mid=(l+r)/2;
	int lef=node*2,rig=node*2+1;
	int f=query(lef,l,mid,L1,R,val);
	int s=query(rig,mid+1,r,L1,R,val);
	return f+s;
}
int main(){
	FAST;
	//freopen("test.in","r",stdin);
	LL a,b;
	cin>>a>>b;
	v.push_back(0);
	LL ar[a];
	for(LL i=1;i<=a;i++){
		cin>>ar[i];
		v.push_back(ar[i]+v[v.size()-1]);
	}
	build(1,1,a);
	LL tot=0;
	for(LL i=1;i<=a;i++){
		LL res=query(1,1,a,i,a,v[i-1]+b);
		//cout<<res<<endl;
		tot+=res;
	}
	cout<<tot<<endl;
	cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


//-----------------
//author: d0uch3b4g
//-----------------

#include "bits/stdc++.h"
#define SIZE          100005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){

        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}

bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

vector<int> tree[4*SIZE];
int ar[SIZE];
vector<LL> v;

void build(int node,int l,int r){
	if(l==r) {
		tree[node].push_back(v[l]);
		return;
	}
	int mid=(l+r)/2;
	int left=node*2,right=node*2+1;
	build(left,l,mid);
	build(right,mid+1,r);
	merge(tree[left].begin(),tree[left].end(),tree[right].begin(),tree[right].end(),back_inserter(tree[node]));
}

LL query(int node,int l,int r,int L1,int R,LL val){
	if(l>R||r<L1) return 0;
	else if(l>=L1 and r<=R){
		return lower_bound(tree[node].begin(),tree[node].end(),val)-tree[node].begin();
	}
	int mid=(l+r)/2;
	int lef=node*2,rig=node*2+1;
	int f=query(lef,l,mid,L1,R,val);
	int s=query(rig,mid+1,r,L1,R,val);
	return f+s;
}
int main(){
	FAST;
	//freopen("test.in","r",stdin);
	int a,b;
	cin>>a>>b;
	v.push_back(0);
	for(int i=1;i<=a;i++){
		cin>>ar[i];
		v.push_back(ar[i]+v[v.size()-1]);
	}
	build(1,1,a);
	LL tot=0;
	for(LL i=1;i<=a;i++){
		LL res=query(1,1,a,i,a,v[i-1]+b);
		//cout<<res<<endl;
		tot+=res;
	}
	cout<<tot<<endl;
	cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


//-----------------
//author: d0uch3b4g
//-----------------

#include "bits/stdc++.h"
#define SIZE          100005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){

        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}

bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

vector<int> tree[4*SIZE];
vector<LL> v;

void build(int node,int l,int r){
	if(l==r) {
		tree[node].push_back(v[l]);
		return;
	}
	int mid=(l+r)/2;
	int left=node*2,right=node*2+1;
	build(left,l,mid);
	build(right,mid+1,r);
	merge(tree[left].begin(),tree[left].end(),tree[right].begin(),tree[right].end(),back_inserter(tree[node]));
}

LL query(int node,int l,int r,int L1,int R,LL val){
	if(l>R||r<L1) return 0;
	else if(l>=L1 and r<=R){
		return lower_bound(tree[node].begin(),tree[node].end(),val)-tree[node].begin();
	}
	int mid=(l+r)/2;
	int lef=node*2,rig=node*2+1;
	int f=query(lef,l,mid,L1,R,val);
	int s=query(rig,mid+1,r,L1,R,val);
	return f+s;
}
int main(){
	FAST;
	//freopen("test.in","r",stdin);
	LL a,b;
	cin>>a>>b;
	v.push_back(0);
	LL ar[a];
	for(int i=1;i<=a;i++){
		cin>>ar[i];
		v.push_back(ar[i]+v[v.size()-1]);
	}
	build(1,1,a);
	LL tot=0;
	for(LL i=1;i<=a;i++){
		LL res=query(1,1,a,i,a,v[i-1]+b);
		//cout<<res<<endl;
		tot+=res;
	}
	cout<<tot<<endl;
	cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


//-----------------
//author: d0uch3b4g
//-----------------

#include "bits/stdc++.h"
#define SIZE          100005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){

        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}

bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

vector<int> tree[4*SIZE];
vector<LL> v;

void build(int node,int l,int r){
	if(l==r) {
		tree[node].push_back(v[l]);
		return;
	}
	int mid=(l+r)/2;
	int left=node*2,right=node*2+1;
	build(left,l,mid);
	build(right,mid+1,r);
	merge(tree[left].begin(),tree[left].end(),tree[right].begin(),tree[right].end(),back_inserter(tree[node]));
}

LL query(int node,int l,int r,int L1,int R,LL val){
	if(l>R||r<L1) return 0;
	else if(l>=L1 and r<=R){
		return lower_bound(tree[node].begin(),tree[node].end(),val)-tree[node].begin();
	}
	int mid=(l+r)/2;
	int lef=node*2,rig=node*2+1;
	int f=query(lef,l,mid,L1,R,val);
	int s=query(rig,mid+1,r,L1,R,val);
	return f+s;
}
int main(){
	FAST;
	//freopen("test.in","r",stdin);
	LL a,b;
	cin>>a>>b;
	v.push_back(0);
	LL ar;
	for(LL i=1;i<=a;i++){
		cin>>ar;
		v.push_back(ar+v[v.size()-1]);
	}
	build(1,1,a);
	LL tot=0;
	for(LL i=1;i<=a;i++){
		LL res=query(1,1,a,i,a,v[i-1]+b);
		//cout<<res<<endl;
		tot+=res;
	}
	cout<<tot<<endl;
	cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


//-----------------
//author: d0uch3b4g
//-----------------

#include "bits/stdc++.h"
#define SIZE          100005
#define REM           1000000007
#define PI            2*acos(0.0)
#define L             long
#define LL            long long
#define UL            unsigned long
#define ULL           unsigned long long
#define TERMINATE     return 0
#define FAST          ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template <class T> inline T bigmod1(T p,T e,T M){
    LL ret=1;
    for(; e > 0; e >>= 1){

        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcode(T a,T b){if(b==0)return a;return gcode(b,a%b);}
template <class T> inline T modularinv(T a,T M){return bigmod1(a,M-2,M);}

bool SA(const pair<string,string> &a, const pair<string,string> &b){
   return a.second<b.second;
}
bool FA(const pair<string,string> &a, const pair<string,string> &b){
   return a.first<b.first;
}
bool SD(const pair<LL,LL> &a, const pair<LL,LL> &b){
   return a.second>b.second;
}
bool FD(const pair<int,int> &a, const pair<int,int> &b){
   return a.first>b.first;
}
//int dirA[8]={0,0,1,-1,1,-1,1,-1};
//int dirB[8]={1,-1,0,0,1,-1,-1,1};
//int dirA[4]={0,0,1,-1};
//int dirB[4]={1,-1,0,0};
//int kingsA[8]={0,0,1,-1,-1,1,-1,1};  //Kings Move
//int kingsB[8]={-1,1,0,0,1,1,-1,-1};  //Kings Move
//int knightsA[8]={-2,-2,-1,-1,1,1,2,2};  //Knights Move
//int knightsB[8]={-1,1,-2,2,-2,2,-1,1};  //Knights Move

vector<int> tree[4*SIZE];
int ar[SIZE];
vector<LL> v;

void build(int node,int l,int r){
	if(l==r) {
		tree[node].push_back(v[l]);
		return;
	}
	int mid=(l+r)/2;
	int left=node*2,right=node*2+1;
	build(left,l,mid);
	build(right,mid+1,r);
	merge(tree[left].begin(),tree[left].end(),tree[right].begin(),tree[right].end(),back_inserter(tree[node]));
}

LL query(int node,int l,int r,int L1,int R,LL val){
	if(l>R||r<L1) return 0;
	else if(l>=L1 and r<=R){
		return lower_bound(tree[node].begin(),tree[node].end(),val)-tree[node].begin();
	}
	int mid=(l+r)/2;
	int lef=node*2,rig=node*2+1;
	int f=query(lef,l,mid,L1,R,val);
	int s=query(rig,mid+1,r,L1,R,val);
	return f+s;
}
int main(){
	FAST;
	//freopen("test.in","r",stdin);
	LL a,b;
	cin>>a>>b;
	v.push_back(0);
	for(int i=1;i<=a;i++){
		cin>>ar[i];
		v.push_back(ar[i]+v[v.size()-1]);
	}
	build(1,1,a);
	LL tot=0;
	for(LL i=1;i<=a;i++){
		LL res=query(1,1,a,i,a,v[i-1]+b);
		//cout<<res<<endl;
		tot+=res;
	}
	cout<<tot<<endl;
	cerr<<"time elapsed:"<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int a[200005];
vector<long> tree[4*200005];
long ans=0;
void mergeSegment(long node,long st,long en,long t){
    if(st>en)
    return;
    if(st==en){
        vector<long> s;
        s.push_back(a[en]);
        if(a[en]<t)
        ans+=(long long)1;
        tree[node]=s;
        return;
    }
    long m=(st+en)/2;
    mergeSegment(2*node+1,st,m,t);
    mergeSegment(2*node+2,m+1,en,t);
    vector<long> ss=tree[2*node+1];
    long n=ss.size()-1;
    long curr=0;
    long pos=-1;
    for(int i=m+1;i<=en;i++){
        curr+=a[i];
        long afford=(t-curr);
        long l=0,h=n;
        while(l<=h){
            long m1=(l+h)/2;
            if(ss[m1]<afford){
                pos=m1;
                l=m1+1;
            }
            else
            h=m1-1;
        }
        ans+=(long long)(pos+1);
        pos=-1;
    }
    vector<long> sb;
    long x=0;
    for(int i=en;i>=st;i--){
        x+=a[i];
        sb.push_back(x);
    }
    sort(sb.begin(),sb.end());
    tree[node]=sb;
}
int main() {
    long int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    mergeSegment(0,0,n-1,t);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int a[200005];
vector<long> tree[4*200005];
long long ans=0;
void mergeSegment(long node,long st,long en,long long t){
    if(st>en)
    return;
    if(st==en){
        vector<long> s;
        s.push_back(a[en]);
        if(a[en]<t)
        ans++;
        tree[node]=s;
        return;
    }
    long m=(st+en)/2;
    mergeSegment(2*node+1,st,m,t);
    mergeSegment(2*node+2,m+1,en,t);
    vector<long> ss=tree[2*node+1];
    long n=ss.size()-1;
    long curr=0;
    long pos=-1;
    for(int i=m+1;i<=en;i++){
        curr+=a[i];
        long afford=(t-curr);
        long l=0,h=n;
        while(l<=h){
            long m1=(l+h)/2;
            if(ss[m1]<afford){
                pos=m1;
                l=m1+1;
            }
            else
            h=m1-1;
        }
        ans+=(long long)(pos+1);
        pos=-1;
    }
    vector<long> sb;
    long long x=0;
    for(int i=en;i>=st;i--){
        x+=a[i];
        sb.push_back(x);
    }
    sort(sb.begin(),sb.end());
    tree[node]=sb;
}
int main() {
    long long int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    mergeSegment(0,0,n-1,t);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long int a[200005];
vector<long long> tree[4*200005];
long long ans=0;
void mergeSegment(long long node,long long st,long long en,long long t){
    if(st>en)
    return;
    if(st==en){
        vector<long long> s;
        s.push_back(a[en]);
        if(a[en]<t)
        ans++;
        tree[node]=s;
        return;
    }
    long long m=(st+en)/2;
    mergeSegment(2*node+1,st,m,t);
    mergeSegment(2*node+2,m+1,en,t);
    vector<long long> ss=tree[2*node+1];
    long long n=ss.size()-1;
    long long curr=0;
    long long pos=-1;
    for(int i=m+1;i<=en;i++){
        curr+=a[i];
        long long afford=(t-curr);
        long long l=0,h=n;
        while(l<=h){
            long long m1=(l+h)/2;
            if(ss[m1]<afford){
                pos=m1;
                l=m1+1;
            }
            else
            h=m1-1;
        }
        ans+=(long long)(pos+1);
        pos=-1;
    }
    vector<long long> sb;
    long long x=0;
    for(int i=en;i>=st;i--){
        x+=a[i];
        sb.push_back(x);
    }
    sort(sb.begin(),sb.end());
    tree[node]=sb;
}
int main() {
    long long int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    mergeSegment(0,0,n-1,t);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int a[200005];
vector<long long> tree[4*200005];
long long ans=0;
void mergeSegment(long node,long st,long en,long long t){
    if(st>en)
    return;
    if(st==en){
        vector<long long> s;
        s.push_back(a[en]);
        if(a[en]<t)
        ans++;
        tree[node]=s;
        return;
    }
    long m=(st+en)/2;
    mergeSegment(2*node+1,st,m,t);
    mergeSegment(2*node+2,m+1,en,t);
    vector<long long> ss=tree[2*node+1];
    long n=ss.size()-1;
    long curr=0;
    long pos=-1;
    for(int i=m+1;i<=en;i++){
        curr+=a[i];
        long afford=(t-curr);
        long l=0,h=n;
        while(l<=h){
            long m1=(l+h)/2;
            if(ss[m1]<afford){
                pos=m1;
                l=m1+1;
            }
            else
            h=m1-1;
        }
        ans+=(long long)(pos+1);
        pos=-1;
    }
    vector<long long> sb;
    long long x=0;
    for(int i=en;i>=st;i--){
        x+=a[i];
        sb.push_back(x);
    }
    sort(sb.begin(),sb.end());
    tree[node]=sb;
}
int main() {
    long long int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    mergeSegment(0,0,n-1,t);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int a[200005];
vector<long> tree[4*200005];
long ans=0;
void mergeSegment(long node,long st,long en,long long t){
    if(st>en)
    return;
    if(st==en){
        vector<long> s;
        s.push_back(a[en]);
        if(a[en]<t)
        ans++;
        tree[node]=s;
        return;
    }
    long m=(st+en)/2;
    mergeSegment(2*node+1,st,m,t);
    mergeSegment(2*node+2,m+1,en,t);
    vector<long> ss=tree[2*node+1];
    long n=ss.size()-1;
    long curr=0;
    long pos=-1;
    for(int i=m+1;i<=en;i++){
        curr+=a[i];
        long afford=(t-curr);
        long l=0,h=n;
        while(l<=h){
            long m1=(l+h)/2;
            if(ss[m1]<afford){
                pos=m1;
                l=m1+1;
            }
            else
            h=m1-1;
        }
        ans+=(long long)(pos+1);
        pos=-1;
    }
    vector<long> sb;
    long long x=0;
    for(int i=en;i>=st;i--){
        x+=a[i];
        sb.push_back(x);
    }
    sort(sb.begin(),sb.end());
    tree[node]=sb;
}
int main() {
    long long int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    mergeSegment(0,0,n-1,t);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int a[200005];
vector<long long> tree[4*200005];
long long ans=0;
void mergeSegment(long node,long st,long en,long long t){
    if(st>en)
    return;
    if(st==en){
        vector<long long> s;
        s.push_back(a[en]);
        if(a[en]<t)
        ans++;
        tree[node]=s;
        return;
    }
    long m=(st+en)/2;
    mergeSegment(2*node+1,st,m,t);
    mergeSegment(2*node+2,m+1,en,t);
    vector<long long> ss=tree[2*node+1];
    long n=ss.size()-1;
    long curr=0;
    long pos=-1;
    for(int i=m+1;i<=en;i++){
        curr+=a[i];
        long afford=(t-curr);
        long l=0,h=n;
        while(l<=h){
            long m1=(l+h)/2;
            if(ss[m1]<afford){
                pos=m1;
                l=m1+1;
            }
            else
            h=m1-1;
        }
        ans+=(long long)(pos+1);
        pos=-1;
    }
    vector<long long> sb;
    long long x=0;
    for(int i=en;i>=st;i--){
        x+=(long long)a[i];
        sb.push_back(x);
    }
    sort(sb.begin(),sb.end());
    tree[node]=sb;
}
int main() {
    long long int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    mergeSegment(0,0,n-1,t);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int a[200005];
vector<long long> tree[4*200005];
long long ans=0;
void mergeSegment(long node,long st,long en,long long t){
    if(st>en)
    return;
    if(st==en){
        vector<long> s;
        s.push_back(a[en]);
        if(a[en]<t)
        ans++;
        tree[node]=s;
        return;
    }
    long m=(st+en)/2;
    mergeSegment(2*node+1,st,m,t);
    mergeSegment(2*node+2,m+1,en,t);
    vector<long> ss=tree[2*node+1];
    long n=ss.size()-1;
    long curr=0;
    long pos=-1;
    for(int i=m+1;i<=en;i++){
        curr+=a[i];
        long afford=(t-curr);
        long l=0,h=n;
        while(l<=h){
            long m1=(l+h)/2;
            if(ss[m1]<afford){
                pos=m1;
                l=m1+1;
            }
            else
            h=m1-1;
        }
        ans+=(long long)(pos+1);
        pos=-1;
    }
    vector<long> sb;
    long long x=0;
    for(int i=en;i>=st;i--){
        x+=a[i];
        sb.push_back(x);
    }
    sort(sb.begin(),sb.end());
    tree[node]=sb;
}
int main() {
    long long int n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    mergeSegment(0,0,n-1,t);
    cout<<ans<<endl;
    return 0;
}