The only difference between easy and hard versions is constraints.

If you write a solution in Python, then prefer to send it in PyPy to speed up execution time.

A session has begun at Beland State University. Many students are taking exams.

Polygraph Poligrafovich is going to examine a group of n students. Students will take the exam one-by-one in order from 1-th to n-th. Rules of the exam are following:

  * The i-th student randomly chooses a ticket. 
  * if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam. 
  * if the student finds the ticket easy, he spends exactly t_i minutes to pass the exam. After it, he immediately gets a mark and goes home. 



Students take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.

The duration of the whole exam for all students is M minutes (max t_i ≤ M), so students at the end of the list have a greater possibility to run out of time to pass the exam.

For each student i, you should count the minimum possible number of students who need to fail the exam so the i-th student has enough time to pass the exam.

For each student i, find the answer independently. That is, if when finding the answer for the student i_1 some student j should leave, then while finding the answer for i_2 (i_2>i_1) the student j student does not have to go home.

Input

The first line of the input contains two integers n and M (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ M ≤ 2 ⋅ 10^7) — the number of students and the total duration of the exam in minutes, respectively.

The second line of the input contains n integers t_i (1 ≤ t_i ≤ 100) — time in minutes that i-th student spends to answer to a ticket.

It's guaranteed that all values of t_i are not greater than M.

Output

Print n numbers: the i-th number must be equal to the minimum number of students who have to leave the exam in order to i-th student has enough time to pass the exam.

Examples

Input


7 15
1 2 3 4 5 6 7


Output


0 0 0 0 0 2 3 

Input


5 100
80 40 40 40 60


Output


0 1 1 2 3 

Note

The explanation for the example 1.

Please note that the sum of the first five exam times does not exceed M=15 (the sum is 1+2+3+4+5=15). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are 0.

In order for the 6-th student to pass the exam, it is necessary that at least 2 students must fail it before (for example, the 3-rd and 4-th, then the 6-th will finish its exam in 1+2+5+6=14 minutes, which does not exceed M).

In order for the 7-th student to pass the exam, it is necessary that at least 3 students must fail it before (for example, the 2-nd, 5-th and 6-th, then the 7-th will finish its exam in 1+3+4+7=15 minutes, which does not exceed M).
import java.io.*;
import java.util.*;
import java.util.Queue;
import java.util.LinkedList;
import java.util.Stack;

public class Main
{
      @SuppressWarnings("unchecked")
        static Reader ob=new Reader();
       static Writer out=new Writer(System.out);
       static Random oo=new Random();
      public static void main(String args[])throws IOException
    {
        int n=ob.nI(),m=ob.nI();
        int a[]=ob.NIA(n);
        int ans[]=new int[n],sum=0;
        int t[]=new int[1000];
        for(int i=0;i<n;i++)
        {
            sum+=a[i];
            int dup=sum,c=0;
            if(dup<=m)
            ans[i]=0;
            else
            {
                for(int j=100;j>=1;j--)
                {
                    if(t[j]>0)
                    {
                        int dif=dup-m;
                        int r=(int)Math.ceil(1.0*dif/j);
                        int p=min(t[j],r);
                        c+=p;
                        dup-=(p*j);
                        if(dup<=m)
                        break;
                    }
                }
                
                
            }
            t[a[i]]++;
            ans[i]=c;
            
        }
        for(int  i=0;i<n;i++)
        out.p(ans[i]+" ");
        
out.flush();
}
static void sort(int a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static Pairs[] RA(Pairs [] array){
        Random rgen = new Random();  // Random number generator         
 
        for (int i=0; i<array.length; i++) {
            int randomPosition = rgen.nextInt(array.length);
            Pairs temp = array[i];
            array[i] = array[randomPosition];
            array[randomPosition] = temp;
        }
 
        return array;
    }
    
 public static int[] RA(int [] array){
        Random rgen = new Random();  // Random number generator         
 
        for (int i=0; i<array.length; i++) {
            int randomPosition = rgen.nextInt(array.length);
            int temp = array[i];
            array[i] = array[randomPosition];
            array[randomPosition] = temp;
        }
 
        return array;
    }
    static void sort(long a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static long[] RA(long [] array){
        Random rgen = new Random();  // Random number generator         
 
        for (int i=0; i<array.length; i++) {
            int randomPosition = rgen.nextInt(array.length);
            long temp = array[i];
            array[i] = array[randomPosition];
            array[randomPosition] = temp;
        }
 
        return array;
    }
    static void sort(String a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static String[] RA(String [] array){
        Random rgen = new Random();  // Random number generator         
 
        for (int i=0; i<array.length; i++) {
            int randomPosition = rgen.nextInt(array.length);
            String temp = array[i];
            array[i] = array[randomPosition];
            array[randomPosition] = temp;
        }
 
        return array;
    }
static long inverse(long x, long p)
    {
        return pow(x, p - 2, p);
    }
static boolean isPrime(long n)
{
    long h=(long)Math.sqrt(n);
    for(long i=2;i<=h;i++)
    if(n%i==0)
    return false;
    return true&&n!=1;
}
    static long gcd(long a,long b)
    {
        if(a<b)
        return gcd(b,a);
        else if(b==0)
        return a;
        else
        return gcd(b,a%b);
    }
    static long pow(long a,long b,long mod){
        if(b == 0)  return 1;
        long t = pow(a,b>>1,mod);
        t = (t * t) % mod;
        if((b & 1) == 1)    t = (t * a);
        if(t >= mod)    t %= mod;
        return t;
}
    static long pow(long a,long b){
        if(b == 0)  return 1;
        long t = pow(a,b>>1);
        t = (t * t);
        if((b & 1) == 1)    t = (t * a);
        return t;
}
    static void seive(int n,int prime[])//smallest factor greater than 1
    {
        for(int i=2;i<=n;i++)
            if(prime[i]==0)
            {
                prime[i]=i;
                for(int j=i;j*i<=n;j++)
                if(prime[j*i]==0)
                prime[j*i]=i;
            }
    }
    static int max(int ...a)
    {
        int m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.max(m,a[i]);
        return m;
        
    }
    static long max(long ...a)
    {
        long m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.max(m,a[i]);
        return m;
    }
    static int min(int ...a)
    {
        int m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.min(m,a[i]);
        return m;
    }
    static long min(long ...a)
    {
        long m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.min(m,a[i]);
        return m;
    }
    static class Pair<T1,T2>
    {
        T1 x;T2 y;
        Pair(T1 xx,T2 yy)
        {
            x=xx;
            y=yy;
        }
    }
    
    static class Writer {
        private final PrintWriter p;
        Writer(OutputStream o) {
            p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(o)));
        }
        void p(Object... o1) {
            for (Object o11 : o1) {
                p.print(o11 + "" );
            }
        }
        <T>void pa(T a[])
        {
            for(T i:a)
            System.out.print(i+" ");
            System.out.println();
          }
        void p(String s) {
            p.print(s);
        }
        void pln(Object... o1) {
            p(o1);
            p.println();
        }
        void flush() {
            p.flush();
        }
        void close() {
            p.close();
        }
    }
    static class Reader {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int snumChars;
        int flag=0;
        FileReader file;
        Reader()
        {
          }
          Reader(String x)throws IOException
          {
              flag=1;
              file=new FileReader(x);
          }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = System.in.read(buf);
                
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public String nl() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public String n() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public long nL() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int nI() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] NIA(int n) //nextINtArray
        {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nI();
            }
            return arr;
        }
        public int[] NIA1(int n) //nextINtArray
        {
            int[] arr = new int[n+1];
            for (int i = 1; i <=n; i++) {
                arr[i] = nI();
            }
            return arr;
        }
        
        public long[] NLA(int n) //nextLongArray
        {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nL();
            }
            return arr;
}
        public long[] NLA1(int n) //nextLongArray
        {
            long[] arr = new long[n+1];
            for (int i = 1; i <=n; i++) {
                arr[i] = nL();
            }
            return arr;
}
        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
static class DSU
{
    int a[],size[],c=1,m;
    HashMap<String,Integer> hm=new HashMap<String,Integer>();
    DSU(int n)
    {
        a=new int[n+1];
        m=n;
        size=new int[n+1];
        for(int i=1;i<=n;i++)
    {
        a[i]=i;
        size[i]=1;
    }
    }
    void add(String x,int i)
    {
        hm.put(x,i);
    }
    int find(int n)
    {
        while(a[n]!=n)
        {
            a[n]=a[a[n]];
        n=a[n];
    }
        return n;
    }
    int[] eval()
    {
       int y[]=new int[m+1];
       for(int i=1;i<=m;i++)
       y[find(i)]++;
       return y;
    }
    void union(int a1,int b)
    {
        int x=find(a1);
        int y=find(b);
        if(size[x]>size[y])
    {
        a[y]=x;
        size[x]+=size[y];
    }
    else
    {
       a[x]=y;
       size[y]+=size[x];
    }
}
        //System.out.println(Arrays.toString(a));
}
class Segment
{
    int sum[];
    void build(int a[],int v,int l,int r)
    {
        if(l==r)
        sum[v]=a[l];
        else
        {
            int m=(l+r)/2;
            build(a,v*2,l,m);
            build(a,2*v+1,m+1,r);
            sum[v]=sum[v*2]+sum[2*v+1];
        }
    }
    void update(int a[],int l,int r,int x,int v,int y)
    {
        if(l==r&&r==y)
            sum[v]+=x;
        else if(l>y||y>r)
        return;
        else
        {
            int m=(l+r)/2;
            update(a,l,m,x,2*v,y);
            update(a,m+1,r,x,2*v+1,y);
            sum[v]=sum[2*v]+sum[2*v+1];
        }
    }
    int query(int v,int l,int r,int x,int y)
    {
        if(x>r||y<l)
        return 0;
        else if(x<=l&&r<=y)
        return sum[v];
        else
        {
            int m=(l+r)/2;
        return query(2*v,l,m,x,y)+query(2*v+1,m+1,r,x,y);  
    }
}
}

static class Trie
  {
      Trie child[]=new Trie[26];
      int count=0;
    }
   /* void insert(String a)
    {
        Trie tmp=root;
        for(int i=0;i<a.length();i++)
        {
            int v=a.charAt(i)-'a';
            if(tmp.child[v]==null)
            {
                tmp.child[v]=new Trie();
                
            }
                tmp=tmp.child[v];
            }
            if(tmp.count==0)
            r++;
            tmp.count=1;
        }*/
    }
    class Pairs implements Comparable<Pairs>
    {
        long x,y;String z;
        Pairs(long a,long b)
        {
            x=a;y=b;
        }
        @Override
         public int compareTo(Pairs a)
            {
            
            if(a.x>this.x)
            return 1;
            else
            return -1;
        }
    }