#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#define INF 1000000000
const int maxn=100005;
int a[maxn],b[maxn],tmp[maxn];
int ta[maxn],tb[maxn];
int A[maxn],B[maxn],C[maxn],D[maxn];
bool ans[maxn];
int n;
void init()
{
    for(int i=0; i<maxn; i++)
        A[i]=B[i]=C[i]=D[i]=0;
}
void solve(int *a,bool sign)
{
    init();
    for(int i=1; i<=n; i++)A[i]=a[i]+A[i-1];
    B[n]=a[n];
    for(int i=n-1; i>=1; i--)B[i]=B[i+1]+a[i];
    C[1]=A[1];
    for(int i=2; i<=n; i++)
    {
        C[i]=C[i-1];
        if(A[i]<C[i-1])C[i]=A[i];
    }
    D[n]=a[n];
    int tmp=a[n];
    for(int i=n-1; i>=1; i--)
    {
        D[i]=D[i+1]+a[i];
        if(D[i]>a[i])D[i]=a[i];
    }
    for(int i=1; i<=n; i++)
        if(i==1&&D[i]>=0)ans[i]=1;
        else if(B[i]+C[i-1]>=0&&D[i]>=0)
        {
            if(!sign)ans[i]=1;
            else ans[n+2-i]=1;
        }
}
void trans()
{
    ta[1]=a[1],tb[1]=b[n];
    for(int i=n; i>=2; i--)
        ta[n+2-i]=a[i],tb[n+2-i]=b[i-1];
    a[1]=ta[1],b[1]=tb[1];
    for(int i=2; i<=n; i++)
        a[i]=ta[i],b[i]=tb[i];
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)scanf("%d",&a[i]);
    for(int i=1; i<=n; i++)scanf("%d",&b[i]);
    if(n==1)printf("1\n1\n");
    else
    {
        for(int i=1; i<=n; i++)tmp[i]=a[i]-b[i];
        solve(tmp,0);
        trans();
        for(int i=1; i<=n; i++)tmp[i]=a[i]-b[i];
        solve(tmp,1);
        int cou=0,flag=0;
        for(int i=1; i<=n; i++)if(ans[i])cou++;
        printf("%d\n",cou);
        for(int i=1; i<=n; i++)
            if(ans[i])
            {
                if(flag)printf(" %d",i);
                else
                {
                    flag=1;
                    printf("%d",i);
                }
            }
        printf("\n");
    }
    return 0;
}

/*lelcjrktdannrqpajjthtntajbdnnbkqsnthdbtgomllagdbqc*/


#include<cstdio>
#include<string.h>
using namespace std;
const int M1 = 110000;

int N;
int a[M1];
int d[M1];
int stop[M1];
int left[M1];
bool ok[2][M1];
int ans[M1];
int len;

inline int getd(int s,int dir);
void dp(int r,int dir); //dir为1时，车从左往右走，-1从右往左走
int main()
{
    //int N;
	scanf("%d",&N);
	for(int i=0;i!=N;++i)
	    scanf("%d",a+i);
	for(int i=0;i!=N;++i)
	    scanf("%d",d+i);
	memset(stop,-1,sizeof(stop));
	memset(left,0,sizeof(left));
    dp(0,1);
	memset(stop,-1,sizeof(stop));
	memset(left,0,sizeof(left));
	dp(1,-1);
	len =0;
	for(int i=0;i!=N;++i)
	{   if(ok[0][i]||ok[1][i])
	        ans[len++] = i+1;
	}
	printf("%d\n",len);
	for(int i=0;i!=len;++i)
	    if(i!=len-1) printf("%d ",ans[i]);
		else printf("%d\n",ans[i]);
    return 0;
}

int getd(int s,int dir)
{
    if(dir==1) return d[s];
	else return d[(s-1+N)%N];
}
void dp(int r,int dir)
{
    int cur=0;
    for(int i=0;i!=N;++i)
	{   int oil = a[cur];
	    int s = cur;
		while(oil>=getd(s,dir))
	    {   oil-=getd(s,dir);
		    if(stop[(s+dir+N)%N]!=-1)
	        {   if(ok[r][(s+dir+N)%N])
			    {   s = cur;
				    oil = a[cur];
				}
				else
			    {   oil += left[(s+dir+N)%N];
				    s = stop[(s+dir+N)%N];
				}
			}
		    else
		    {   s = (s+dir+N)%N;
			    oil += a[s];
			}
			if(s==cur)
			{   ok[r][cur] = true;
			    stop[cur] = s;
		        left[cur] = oil;
			    break;
			}
		}
		if(s!=cur)
		{   stop[cur] = s;
		    left[cur] = oil;
		}
		cur = (cur-dir+N)%N;
	}
}

/*ecerehifaeqlatoshtjjglldaghpkkrhmceibmooicfiblsbki*/


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 200005;
int a[maxn],b[maxn];
int pos[maxn];
int hash[maxn];
int n;
int ans;

int getcal(int x,int y)
{
    if (x==n-1 && y==0) return b[n-1];
    if (y==n-1 && x==0) return b[n-1];
    if (x<=y) return b[x];
    else return b[y];
}
void doit()
{
    int sum=0,l,r;
    l=0;
    r=1;
    while (l<2*n)
    {
        while (sum>=0 && r<2*n)
        {
            sum=sum+a[pos[r-1]]-getcal(pos[r],pos[r-1]);
            r++;
            if (sum==0 && r-1-l==n)
            {
                if (hash[pos[l]]==0)
                {
                    ans++;
                    hash[pos[l]]=1;
                }
                break;//直到一个解答，就到了本次最大扩展的地方，需求移动L指针
            }
        }
        l++;
        sum=sum-a[pos[l-1]]+getcal(pos[l],pos[l-1]);
    }
}
int main()
{
    int i,j;
    while (~scanf("%d",&n))
    {
        for (i=0;i<n;i++)
            scanf("%d",&a[i]);
        for (i=0;i<n;i++)
            scanf("%d",&b[i]);
        memset(hash,0,sizeof(hash));
        ans=0;
        j=0;
        for (i=0;i<2*n;i++)
        {
            pos[i]=j;
            j=(j+1)%n;
        }
        doit();

        j=n-1;
        for (i=1;i<2*n;i++)
        {
            pos[i]=j;
            j--;
            if (j<0) j=n-1;
        }
        doit();
        j=0;
        printf("%d\n",ans);
        for (i=0;i<n;i++)
        {
            if (hash[i]==1)
            {
                j++;
                if (j<ans) printf("%d ",i+1);
                else printf("%d\n",i+1);
            }
        }
    }
    return 0;
}

/*pgfdenjhetjalcrtcjpbfrqkmstsqgfdecsbptilsslcaabpji*/


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 200005;
int a[maxn],b[maxn];
int pos[maxn];
int hash[maxn];
int n;
int ans;

int getcal(int x,int y)
{
    if (x==n-1 && y==0) return b[n-1];
    if (y==n-1 && x==0) return b[n-1];
    if (x<=y) return b[x];
    else return b[y];
}
void doit()
{
    int sum=0,l,r;
    l=0;
    r=1;
    while (l<2*n)
    {
        while (sum>=0 && r<2*n)
        {
            int px = sum;
            sum=sum+a[pos[r-1]]-getcal(pos[r],pos[r-1]);
            r++;
            if (sum==0 && r-1-l==n)
            {
                if (hash[pos[l]]==0)
                {
                    ans++;
                    hash[pos[l]]=1;
                }
                break;
            }
        }
        l++;
        sum=sum-a[pos[l-1]]+getcal(pos[l],pos[l-1]);
    }
}
int main()
{
    int i,j;
    while (~scanf("%d",&n))
    {
        for (i=0;i<n;i++)
            scanf("%d",&a[i]);
        for (i=0;i<n;i++)
            scanf("%d",&b[i]);
        memset(hash,0,sizeof(hash));
        ans=0;
        j=0;
        for (i=0;i<2*n;i++)
        {
            pos[i]=j;
            j=(j+1)%n;
        }
        doit();

        j=n-1;
        for (i=1;i<2*n;i++)
        {
            pos[i]=j;
            j--;
            if (j<0) j=n-1;
        }
        doit();
        j=0;
        for (i=0;i<n;i++)
        {
            if (hash[i]==1)
            {
                j++;
                if (j<ans) printf("%d ",i+1);
                else printf("%d\n",i+1);
            }
        }
    }
    return 0;
}

/*gocccsncslsmegbbpqfcfbcacprhhmjfslinbnhaefmidfbkbs*/


#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
const int mod=1;
const int eps=1e-6;
//
const int limit=200000+1;
int n;
int a[limit];
int b[limit];
int lp[limit];
bool can[limit]={false};
int ra[limit];
int rb[limit];
vector <int> v;
void workr()
{
    for(int i=1;i<=2*n;i++)
    {
        lp[i]=a[i]-b[i];
    }
    int cur=0;
    int p=1;
    for(int i=1;i<=n;)
    {
        while(cur<0)
        {
            cur-=lp[i];
            i++;
            if(i>n)
              return;
        }
        if(lp[p]+cur>=0)
        {
            cur+=lp[p];
            p++;
            if(p-i>=n)
            {
                if(!can[i])
                {
                    can[i]=true;
                    v.push_back(i);
                }
                cur-=lp[i];
                i++;
            }
        }
        else
        {
            while(cur+lp[p]<0)
            {
                cur-=lp[i];
                i++;
            }
        }
    }
}
void workl()
{
    for(int i=1;i<=2*n;i++)
    {
        ra[i]=a[2*n+1-i];
        if(i!=2*n)
        rb[i]=b[2*n+1-i-1];
        else
        rb[i]=b[2*n];
    }
    memcpy(a+1,ra+1,sizeof(int)*2*n);
    memcpy(b+1,rb+1,sizeof(int)*2*n);
    for(int i=1;i<=2*n;i++)
    {
        lp[i]=a[i]-b[i];
    }
    int cur=0;
    int p=1;
    for(int i=1;i<=n;)
    {
        while(cur<0)
        {
            cur-=lp[i];
            i++;
            if(i>n)
              return;
        }
        if(lp[p]+cur>=0)
        {
            cur+=lp[p];
            p++;
            if(p-i>=n)
            {
                if(!can[n+1-i])
                {
                    can[n+1-i]=true;
                    v.push_back(n+1-i);
                }
                cur-=lp[i];
                i++;
            }
        }
        else
        {
            while(cur+lp[p]<0)
            {
                cur-=lp[i];
                i++;
            }
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",a+i);
    }
    memcpy(a+n+1,a+1,sizeof(int)*n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",b+i);
    }
    memcpy(b+n+1,b+1,sizeof(int)*n);
    workr();
    workl();
    sort(v.begin(),v.end());
    int len=v.size();
    printf("%d\n",len);
    printf("%d",v[0]);
    for(int i=1;i<len;i++)
    {
        printf(" %d",v[i]);
    }
    printf("\n");
    return 0;
}

/*teltpnopliijhckisoacjkbglhdjddidatopmiceilfhfhiena*/


#include <iostream>
using namespace std;
int main()
{
    int i,j,k,ans=0;
    int a[100010];
    int b[100010];
    int ok[100010][2];
    int n;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>a[i];
    for(i=1; i<=n; i++)
        cin>>b[i];
    for(i=1; i<=n; i++)
    {

        int sum=a[i];
        int L=1,R=1;
        //走 右边
        j=i;
        k=0;
        while(1)
        {
            if(j==i) k=1;
            sum-=b[j];
            if(sum<0){ R=0; break; }
            if(j==n) j=1;
            else j++;
            if(ok[j][0]) break;
            sum+=a[j];
            if(j==i&&k) break;

        }
        ok[i][0]=R;
        //左边
        sum=a[i-1];
        j=i;
        k=0;
        while(1)
        {
            cout<<sum<<" ";
            if(j==i) k=1;
            if(j==1) j=n;
            else j--;
            if(sum<b[j]){ L=0;break; }
            sum-=b[j];
           // if(j==1) j=n;
            //else j--;
            if(ok[j][1]) break;
            sum+=a[j];
            if(j==i&&k) break;
        }
        cout<<L<<" 1236 "<<endl;
        ok[i][1]=L;
        cout<<i<<" "<<R<<" "<<L<<endl;
    }
    for(i=1; i<=n; i++)
    {
        if(ok[i][0]||ok[i][1]) ans++;
    }
    cout<<ans<<endl;
    for(i=1; i<=n; i++)
    {
        if(ok[i][0]||ok[i][1])cout<<i<<" ";
    }
}
//4 1 7 2 3 8 1 1 3

/*hmnomejhjrljncktaoflmjsfkkrrhoohhhblekkntncnpmehsc*/


#include <iostream>
using namespace std;
int main()
{
    int i,j,k,ans=0;
    int n;
    cin>>n;
    int a[n+5];
    int b[n+5];
    int ok[n+5][2];

    for(i=1; i<=n; i++)
        cin>>a[i];
    for(i=1; i<=n; i++)
        cin>>b[i];
    for(i=1; i<=n; i++)
    {

        int sum=a[i];
        int L=1,R=1;
        //走 右边
        j=i;
        k=0;
        while(1)
        {
            if(j==i) k=1;
            sum-=b[j];
            if(sum<0){ R=0; break; }
            if(j==n) j=1;
            else j++;
            if(ok[j][0]) break;
            sum+=a[j];
            if(j==i&&k) break;

        }
        ok[i][0]=R;
        //左边
        sum=a[i];
        j=i;
        k=0;
        while(1)
        {
            //cout<<sum<<" ";
            if(j==i) k=1;
            if(j==1) j=n;
            else j--;
            if(sum<b[j]){ L=0;break; }
            sum-=b[j];
           // if(j==1) j=n;
            //else j--;
            if(ok[j][1]) break;
            sum+=a[j];
            if(j==i&&k) break;
        }
        //cout<<L<<" 1236 "<<endl;
        ok[i][1]=L;
        if(ok[i][0]||ok[i][1]) ans++;
        //cout<<i<<" "<<L<<" "<<R<<endl;
    }
   // for(i=1; i<=n; i++)
    //{
        //if(ok[i][0]||ok[i][1]) ans++;
    //}
    cout<<ans<<endl;
    for(i=1; i<=n; i++)
    {
        if(ok[i][0]||ok[i][1])cout<<i<<" ";
    }
}
//4 1 7 2 3 8 1 1 3

/*girigrqetsagbmcgbqaeqkgbtgkhibmgbcpillekbeqoqknktn*/


#include <iostream>
using namespace std;
int main()
{
    int i,j,k,ans=0;
    int n;
    cin>>n;
    int a[n+5];
    int b[n+5];
    int ok[n+5][2];

    for(i=1; i<=n; i++)
        cin>>a[i];
    for(i=1; i<=n; i++)
        cin>>b[i];
    for(i=1; i<=n; i++)
    {

        int sum=a[i];
        int L=1,R=1;
        //走 右边
        j=i;
        k=0;
        while(1)
        {
            if(j==i) k=1;
            sum-=b[j];
            if(sum<0){ R=0; break; }
            if(j==n) j=1;
            else j++;
            //if(ok[j][0]) break;
            sum+=a[j];
            if(j==i&&k) break;

        }
        ok[i][0]=R;
        //左边
        sum=a[i];
        j=i;
        k=0;
        while(1)
        {
            //cout<<sum<<" ";
            if(j==i) k=1;
            if(j==1) j=n;
            else j--;
            if(sum<b[j]){ L=0;break; }
            sum-=b[j];
           // if(j==1) j=n;
            //else j--;
            //if(ok[j][1]) break;
            sum+=a[j];
            if(j==i&&k) break;
        }
        //cout<<L<<" 1236 "<<endl;
        ok[i][1]=L;
        if(ok[i][0]||ok[i][1]) ans++;
        //cout<<i<<" "<<L<<" "<<R<<endl;
    }
   // for(i=1; i<=n; i++)
    //{
        //if(ok[i][0]||ok[i][1]) ans++;
    //}
    cout<<ans<<endl;
    for(i=1; i<=n; i++)
    {
        if(ok[i][0]||ok[i][1])cout<<i<<" ";
    }
}
//4 1 7 2 3 8 1 1 3

/*llmpmitrkdbffmtrbmicjnpjahrcakodcstohkdrnqokjohksh*/


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#define INF 1000000000
const int maxn=100005;
int a[maxn],b[maxn],tmp[maxn];
bool ans[maxn];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)scanf("%d",&a[i]);
    for(int i=1; i<=n; i++)scanf("%d",&b[i]);

    for(int i=1; i<=n; i++)tmp[i]=a[i]-b[i];
    if(tmp[1]<0)
    {
        tmp[n]+=tmp[1];
    }
    for(int i=n; i>=2; i--)
    {
        int j=i;
        while(tmp[j]<0)
        {
            tmp[j-1]+=tmp[j];
            j--;
            if(j==1)break;
        }
        i=j;
    }
    for(int i=1; i<=n; i++)if(tmp[i]>=0)ans[i]=1;
    b[0]=b[n];
    for(int i=1; i<=n; i++)tmp[i]=a[i]-b[i-1];
    if(tmp[n]<0)
    {
        tmp[1]+=tmp[n];
    }
    for(int i=1; i<n; i++)
    {
        int j=i;
        while(tmp[j]<0)
        {
            tmp[j+1]+=tmp[j];
            j++;
            if(j==n)break;
        }
        i=j;
    }
    for(int i=1; i<=n; i++)
        if(tmp[i]>=0)ans[i]=1;
    int cou=0;
    for(int i=1; i<=n; i++)
        if(ans[i])cou++;
    printf("%d\n",cou);
    int flag=0;
    for(int i=1; i<=n; i++)
        if(ans[i])
        {
            if(flag)printf(" %d",i);
            else
            {
                flag=1;
                printf("%d",i);
            }
        }
    printf("\n");
    return 0;
}

/*ibephjsjndtomgqjbckrnqrfglbbaababgijhskbbbpnhdparr*/


#include <iostream>
using namespace std;
int main()
{
    int i,j,k,ans=0;
    int a[100010];
    int b[100010];
    int ok[100010][2];
    int n;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>a[i];
    for(i=1; i<=n; i++)
        cin>>b[i];
    for(i=1; i<=n; i++)
    {

        int sum=a[i];
        int L=1,R=1;
        //走 右边
        j=i;
        k=0;
        while(1)
        {
            if(j==i) k=1;
            sum-=b[j];
            if(sum<0){ R=0; break; }
            if(j==n) j=1;
            else j++;
            if(ok[j][0]) break;
            sum+=a[j];
            if(j==i&&k) break;

        }
        ok[i][0]=R;
        //左边
        sum=a[i];
        j=i;
        k=0;
        while(1)
        {
            //cout<<sum<<" ";
            if(j==i) k=1;
            if(j==1) j=n;
            else j--;
            if(sum<b[j]){ L=0;break; }
            sum-=b[j];
           // if(j==1) j=n;
            //else j--;
            if(ok[j][1]) break;
            sum+=a[j];
            if(j==i&&k) break;
        }
        //cout<<L<<" 1236 "<<endl;
        ok[i][1]=L;
        //cout<<i<<" "<<L<<" "<<R<<endl;
    }
    for(i=1; i<=n; i++)
    {
        if(ok[i][0]||ok[i][1]) ans++;
    }
    cout<<ans<<endl;
    for(i=1; i<=n; i++)
    {
        if(ok[i][0]||ok[i][1])cout<<i<<" ";
    }
}
//4 1 7 2 3 8 1 1 3

/*qggrlmdgkaemkmasbdacdihjdtjrjoprabolfrjpjohlsijalk*/


#include <stdio.h>
#include <algorithm>
using namespace std;
int a[100005];
int b[100005];
long long c[200005];
int st[100005];
int d[1000005], qb=0, qe=0;
int startwith[100005];

int rev(int *r, int n) {
	int i, j;
	for(i=0,j=n-1;i<j;i++,j--) {
		int tmp=r[i];r[i]=r[j];r[j]=tmp;
	}
}
int main(void)
{
	int n, i;
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	for(i=0;i<n;i++)
		scanf("%d", &b[i]);
	for(i=0;i<n;i++)
		c[n+i] = c[i] = (long long)a[i] - (long long)b[i];
	for(i=1;i<2*n;i++)
		c[i] = c[i-1] + c[i];
	qb = qe = 0;
	for(i=0;i<n;i++) {
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
	}
	for(i=n;i<2*n;i++) {
		if(c[d[qb]] >= (i>n?c[i-n-1]:0)) startwith[i-n] = 1;
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
		while(d[qb] <= i-n) ++qb;
	}

	rev(a,n);
	rev(b,n);
	int tmp = a[n-1];
	for(i=n-1;i>0;--i) a[i] = a[i-1];
	a[0] = tmp;
	for(i=0;i<n;i++) st[i] = n-i;
	st[0] = 0;

	for(i=0;i<n;i++)
		c[n+i] = c[i] = (long long)a[i] - (long long)b[i];
	for(i=1;i<2*n;i++)
		c[i] = c[i-1] + c[i];
	qb = qe = 0;
	for(i=0;i<n;i++) {
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
	}
	for(i=n;i<2*n;i++) {
		if(c[d[qb]] >= (i>n?c[i-n-1]:0)) {startwith[st[i-n]] = 1;}
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
		while(d[qb] <= i-n) ++qb;
	}
	int cnt=0;
	for(i=0;i<n;i++)
		if(startwith[i]) ++cnt;
	printf("%d\n", cnt);
	int f=0;
	for(i=0;i<n;i++)
		if(startwith[i]) {
			if(f) printf(" ");
			else f=1;
			printf("%d", i+1);
		}
	printf("\n");
	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
int a[100005];
int b[100005];
long long c[100005];
int st[100005];
int d[1000005], qb=0, qe=0;
int startwith[100005];

int rev(int *r, int n) {
	int i, j;
	for(i=0,j=n-1;i<j;i++,j--) {
		int tmp=r[i];r[i]=r[j];r[j]=tmp;
	}
}
int main(void)
{
	int n, i;
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	for(i=0;i<n;i++)
		scanf("%d", &b[i]);
	for(i=0;i<n;i++)
		c[n+i] = c[i] = (long long)a[i] - (long long)b[i];
	for(i=1;i<2*n;i++)
		c[i] = c[i-1] + c[i];
	qb = qe = 0;
	for(i=0;i<n;i++) {
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
	}
	for(i=n;i<2*n;i++) {
		if(c[d[qb]] >= (i>n?c[i-n-1]:0)) startwith[i-n] = 1;
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
		while(d[qb] <= i-n) ++qb;
	}

	rev(a,n);
	rev(b,n);
	int tmp = a[n-1];
	for(i=n-1;i>0;--i) a[i] = a[i-1];
	a[0] = tmp;
	for(i=0;i<n;i++) st[i] = n-i;
	st[0] = 0;

	for(i=0;i<n;i++)
		c[n+i] = c[i] = (long long)a[i] - (long long)b[i];
	for(i=1;i<2*n;i++)
		c[i] = c[i-1] + c[i];
	qb = qe = 0;
	for(i=0;i<n;i++) {
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
	}
	for(i=n;i<2*n;i++) {
		if(c[d[qb]] >= (i>n?c[i-n-1]:0)) {startwith[st[i-n]] = 1;}
		while(qe>qb && c[d[qe-1]] >= c[i]) --qe;
		d[qe++] = i;
		while(d[qb] <= i-n) ++qb;
	}
	int cnt=0;
	for(i=0;i<n;i++)
		if(startwith[i]) ++cnt;
	printf("%d\n", cnt);
	int f=0;
	for(i=0;i<n;i++)
		if(startwith[i]) {
			if(f) printf(" ");
			else f=1;
			printf("%d", i+1);
		}
	printf("\n");
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int n, a[100001], b[100001];
bool can[100001];
int main()
{
  cin>>n;
  for (int i = 0; i < n; i++) cin>>a[i];
  for (int i = 0; i < n; i++) cin>>b[i];
  int mn = 0, sum = 0;
  for (int i = 0; i < n; i++) sum += a[i] - b[i], mn = min(mn, sum);
  if (mn == 0) can[0] = true;
  for (int i = 1; i < n; i++) {
    mn = min(0, mn - (a[i-1] - b[i-1]));
    if (mn == 0) can[i] = true;
  }
  rotate(b, b+n-1, b+n);
  mn = 0, sum = 0;
  for (int i = n-1; i >= 0; i--) sum += a[i] - b[i], mn = min(mn, sum);
  if (mn == 0) can[n-1] = true;
  for (int i = n-2; i >= 0; i--) {
    mn = min(0, mn - (a[i+1]-b[i+1]));
    if (mn == 0) can[i] = true;
  }
  int ans = 0;
  for (int i = 0; i <= n-1; i++) if (can[i]) ans++;
  cout<<ans<<endl;
  for (int i = 0; i <= n-1; i++) if (can[i]) cout<<i+1<<" ";cout<<endl;

  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int n, a[100001], b[100001];
bool can[100001];
int main()
{
  cin>>n;
  for (int i = 0; i < n; i++) cin>>a[i];
  for (int i = 0; i < n; i++) cin>>b[i];
  int mn = 0, sum = 0;
  for (int i = 0; i < n; i++) sum += a[i] - b[i], mn = min(mn, sum);
  if (mn == 0) can[0] = true;
  for (int i = 1; i < n; i++) {
    mn = min(0, mn - (a[i-1] - b[i-1]));
    if (mn == 0) can[i] = true;
  }
  rotate(b, b+n-1, b+n);
  mn = 0, sum = 0;
  for (int i = n-1; i >= 0; i--) sum += a[i] - b[i], mn = min(mn, sum);
  if (mn == 0) can[n-1] = true;
  for (int i = n-2; i >= 0; i--) {
    mn = min(0, mn - (a[i+1]-b[i+1]));
    if (mn == 0) can[i] = true;
  }
  for (int i = 0; i <= n-1; i++) if (can[i]) cout<<i+1<<" "; cout<<endl;
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;
int main ()
{ int n,i , count=0;
 int a[100010]={0},b[100010]={0} , d[100010]={0} , ans[100010] ,check[100010]={0};
cin>>n;

for (i=1 ; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++)
 { cin>>b[i]; d[i]=a[i]-b[i]+d[i-1];}

int mn=d[1];
for (i=1; i<=n; i++)
if (mn>d[i]) mn=d[i];

for (i=0; i<=n; i++)
{ mn-=(a[i]-b[i]);
 if (mn>=0) {count++; ans[count]=i+1; check[i+1]=1; }
}

memset(d ,0,sizeof(d));

b[0]=b[n];
for (i=n; i>0; i--)
 {d[i]=a[i]-b[i-1]+d[i+1];}

mn=d[1];
for (i=1; i<=n; i++)
if (mn>d[i]) mn=d[i];
/*
for (i=1; i<=n; i++)
cout<<d[i]<<" ";cout<<endl;*/
if (mn>=0 && check[n]==0) { count++; ans[count]=n; check[n]=1; }

for (i=n; i>0; i--)
{ mn-=(a[i]-b[i-1]);
 if (mn>=0) { if (check[i-1]==0) {count++; ans[count]=i-1; check[i-1]=1;} }
}

sort(ans,ans+count);
cout<<count-1<<endl;

for (i=1 ; i<count ; i++)
cout<<ans[i]<<"  ";

//system("pause");
}


#include <stdio.h>
#include <iostream>

using namespace std;
int main ()
{ int n;
cin>>n;
if (n==1) { printf("2"); return 0; }
if (n==2) { printf("-1"); return 0; }

printf("10\n15\n6\n");

if (n>3)
{ int i;
 for (i=2 ; i<n-1 ; i++)
 printf("%lld\n",i*6);
        }
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAXN = 100001;

int n;
int a[MAXN], b[MAXN], d[MAXN];
int x[MAXN];
bool f[MAXN];

int run()
{
    for (int i = 1; i <= n; i++)
        x[i] = x[i - 1] + a[i] - b[i];

    int m = x[1];
    for (int i = 1; i <= n; i++)
        m = min(m, x[i]);

    for (int i = 1; i <= n; i++)
        f[d[i % n + 1]] |= (x[i] == m);

    return 0;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in", "rt", stdin);
        freopen("out", "wt", stdout);
    #endif

    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &b[i]);

    for (int i = 1; i <= n; i++)
        d[i] = i;

    run();

    reverse(a + 1, a + 1 + n);
    reverse(b + 1, b + 1 + n);
    b[n + 1] = b[1];
    memmove(b + 0, b + 1, sizeof(b[0]) * (n + 1));

    for (int i = 1; i <= n; i++)
        d[i] = n - i + 1;

    run();

    int k = 0;
    for (int i = 1; i <= n; i++)
        k += f[i];

    printf("%d\n", k);
    for (int i = 1; i <= n; i++)
        if (f[i])
            printf("%d ", i);
    printf("\n");
    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 100001;

int n;
int a[MAXN], b[MAXN], d[MAXN];
int x[MAXN];
bool f[MAXN];

int run()
{
    for (int i = 1; i <= n; i++)
        x[i] = x[i - 1] + a[i] - b[i];

    int m = x[1];
    for (int i = 1; i <= n; i++)
        m = min(m, x[i]);

    for (int i = 1; i <= n; i++)
        f[d[i % n + 1]] |= (x[i] == m);

    return 0;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in", "rt", stdin);
        freopen("out", "wt", stdout);
    #endif

    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &b[i]);

    for (int i = 1; i <= n; i++)
        d[i] = i;

    run();

    reverse(a + 1, a + 1 + n);
    reverse(b + 1, b + 1 + n);
    b[n + 1] = b[1];
    memmove(b + 0, b + 1, sizeof(b[0]) * (n + 1));

    for (int i = 1; i <= n; i++)
        d[i] = n - i + 1;

    run();

    int k = 0;
    for (int i = 1; i <= n; i++)
        k += f[i];

    printf("%d\n", k);
    for (int i = 1; i <= n; i++)
        if (f[i])
            printf("%d ", i);
    printf("\n");
    return 0;
}


/* Author : RISHAV GOYAL */

#include <bits/stdc++.h>

using namespace std;

#define LL long long int
#define UL unsigned long long int

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

int gcd ( int a, int b ){int c;while(a!= 0){c=a;a=b%a;b=c;}return b;}
LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

LL a[100010],Left[100010],Left2[100010],b[100010];
bool canstart[100001]={false};

int main()
{
	LL n,totaldistance=0,totalfuel=0;
	cin >> n;
	for(int i=1;i<=n;++i) cin >> a[i];
	for(int i=1;i<=n;++i) cin >> b[i];
	for(int iter=1;iter<3;++iter){
		if ( iter==2){
			for(int i=1;i<=n;++i) Left[i] = a[n-i+1];
			for(int i=1;i<=n;++i) a[i] = Left[i];

			for(int i=1;i<=n;++i) Left[i] = b[i];
			for(int i=1;i<n;++i) b[i] = Left[n-i];
			b[n]=Left[n];
			//			return 0;
		}

		totaldistance=totalfuel=0;

		Left[n+1]=0;

		b[0]=b[n];
		Left[n]=0;

		for(int i=n-1;i>0;--i){
			if ( a[i] < b[i]){
				Left[i] = a[i]-b[i];
				if ( Left[i+1] < 0) Left[i] += Left[i+1];
			}
			else{
				Left[i] = a[i] - b[i] + Left[i+1];
			}
		}

		Left2[0] = totalfuel = totaldistance = 0 ;
		a[0]=a[n];
		b[0]=b[n];
		for( int i=1;i<=n;++i){
			if ( max(- Left2[i-1] ,(long long int)(0)) + totalfuel - totaldistance + a[i-1] >= b[i-1]){
				Left2[i] = Left2[i-1];
			}
			else{
				Left2[i] = -  (totaldistance + b[i-1] - a[i-1] - totalfuel );
			}
			//		cout << i << " "<< Left2[i] << endl;
			totaldistance += b[i-1];
			totalfuel += a[i-1];
		}
		if ( iter == 1){
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && Left[i]+Left2[i]>=0) canstart[i]=true;
			}
		}
		else{
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && Left[i]+Left2[i]>=0) canstart[n-i+1]=true;
			}
		}
		//		pr();
	}
	int k=0;
	for(int i=1;i<=n;++i) {
		if (canstart[i])++k;
	}
	for(int i=1;i<=n;++i){
		if ( canstart[i] ){
			printf("%d",i);
			k--;
			if ( k)printf(" ");
		}
	}
	printf("\n");
	return 0;
}


/* Author : RISHAV GOYAL */

#include <bits/stdc++.h>

using namespace std;

#define LL long long int
#define UL unsigned long long int

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

int gcd ( int a, int b ){int c;while(a!= 0){c=a;a=b%a;b=c;}return b;}
LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

LL a[100010],Left[100010],Left2[100010],b[100010];
bool canstart[100001]={false};

int main()
{
	LL n,totaldistance=0,totalfuel=0;
	cin >> n;
	for(int i=1;i<=n;++i) cin >> a[i];
	for(int i=1;i<=n;++i) cin >> b[i];
	for(int iter=1;iter<3;++iter){
		if ( iter==2){
			for(int i=1;i<=n;++i) Left[i] = a[n-i+1];
			for(int i=1;i<=n;++i) a[i] = Left[i];

			for(int i=1;i<=n;++i) Left[i] = b[i];
			for(int i=1;i<n;++i) b[i] = Left[n-i];
			b[n]=Left[n];
			//			return 0;
		}

		totaldistance=totalfuel=0;

		Left[n+1]=0;

		b[0]=b[n];
		Left[n]=0;

		for(int i=n-1;i>0;--i){
			if ( a[i] < b[i]){
				Left[i] = a[i]-b[i];
				if ( Left[i+1] < 0) Left[i] += Left[i+1];
			}
			else{
				Left[i] = a[i] - b[i] + Left[i+1];
			}
		}

		Left2[0] = totalfuel = totaldistance = 0 ;
		a[0]=a[n];
		b[0]=b[n];
		for( int i=1;i<=n;++i){
			if ( max(- Left2[i-1] ,0) + totalfuel - totaldistance + a[i-1] >= b[i-1]){
				Left2[i] = Left2[i-1];
			}
			else{
				Left2[i] = -  (totaldistance + b[i-1] - a[i-1] - totalfuel );
			}
			//		cout << i << " "<< Left2[i] << endl;
			totaldistance += b[i-1];
			totalfuel += a[i-1];
		}
		if ( iter == 1){
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && Left[i]+Left2[i]>=0) canstart[i]=true;
			}
		}
		else{
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && Left[i]+Left2[i]>=0) canstart[n-i+1]=true;
			}
		}
		//		pr();
	}
	int k=0;
	for(int i=1;i<=n;++i) {
		if (canstart[i])++k;
	}
	for(int i=1;i<=n;++i){
		if ( canstart[i] ){
			printf("%d",i);
			k--;
			if ( k)printf(" ");
		}
	}
	printf("\n");
	return 0;
}


/* Author : RISHAV GOYAL */

#include <bits/stdc++.h>

using namespace std;

#define LL long long int
#define UL unsigned long long int

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

int gcd ( int a, int b ){int c;while(a!= 0){c=a;a=b%a;b=c;}return b;}
LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

LL a[100010],Left[100010],Left2[100010],b[100010];
bool canstart[100001]={false};

int main()
{
	LL n,totaldistance=0,totalfuel=0;
	cin >> n;
	for(int i=1;i<=n;++i) cin >> a[i];
	for(int i=1;i<=n;++i) cin >> b[i];
	for(int iter=1;iter<3;++iter){
		if ( iter==2){
			for(int i=1;i<=n;++i) Left[i] = a[n-i+1];
			for(int i=1;i<=n;++i) a[i] = Left[i];

			for(int i=1;i<=n;++i) Left[i] = b[i];
			for(int i=1;i<n;++i) b[i] = Left[n-i];
			b[n]=Left[n];
			//			return 0;
		}

		totaldistance=totalfuel=0;

		Left[n+1]=0;

		b[0]=b[n];
		Left[n]=0;

		for(int i=n-1;i>0;--i){
			if ( a[i] < b[i]){
				Left[i] = a[i]-b[i];
				if ( Left[i+1] < 0) Left[i] += Left[i+1];
			}
			else{
				Left[i] = a[i] - b[i] + Left[i+1];
			}
		}

		Left2[0] =0;
		totalfuel =0; totaldistance = 0 ;
		a[0]=a[n];
		b[0]=b[n];
		for( int i=1;i<=n;++i){
			if ( max(- Left2[i-1] ,(long long int)(0)) + totalfuel - totaldistance + a[i-1] >= b[i-1]){
				Left2[i] = Left2[i-1];
			}
			else{
				Left2[i] =  0-(totaldistance + b[i-1] - a[i-1] - totalfuel );
			}
			totaldistance += b[i-1];
			totalfuel += a[i-1];
		}
		totaldistance=totalfuel=0;
		for(int i=1;i<n;++i) {
			totalfuel += a[i];
			totaldistance += b[i];
		}
		if ( iter == 1){
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && totalfuel-totaldistance+Left2[i]>=0) canstart[i]=true;
				totalfuel -= a[i];
				totaldistance -= b[i];
			}
		}
		else{
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && totalfuel-totaldistance+Left2[i]>=0) canstart[n-i+1]=true;
				totalfuel -= a[i];
				totaldistance -= b[i];
			}
		}
	}
	int k=0;
	for(int i=1;i<=n;++i) {
		if (canstart[i])++k;
	}
	cout << k << endl;
	for(int i=1;i<=n;++i){
		if ( canstart[i] ){
			printf("%d",i);
			k--;
			if ( k)printf(" ");
		}
	}
	printf("\n");
	return 0;
}


/* Author : RISHAV GOYAL */

#include <bits/stdc++.h>

using namespace std;

#define LL long long int
#define UL unsigned long long int

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

int gcd ( int a, int b ){int c;while(a!= 0){c=a;a=b%a;b=c;}return b;}
LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

LL a[100010],Left[100010],Left2[100010],b[100010];
bool canstart[100001]={false};

int main()
{
	LL n,totaldistance=0,totalfuel=0;
	cin >> n;
	for(int i=1;i<=n;++i) cin >> a[i];
	for(int i=1;i<=n;++i) cin >> b[i];
	for(int iter=1;iter<3;++iter){
		if ( iter==2){
			for(int i=1;i<=n;++i) Left[i] = a[n-i+1];
			for(int i=1;i<=n;++i) a[i] = Left[i];

			for(int i=1;i<=n;++i) Left[i] = b[i];
			for(int i=1;i<n;++i) b[i] = Left[n-i];
			b[n]=Left[n];
			//			return 0;
		}

		totaldistance=totalfuel=0;

		Left[n+1]=0;

		b[0]=b[n];
		Left[n]=0;

		for(int i=n-1;i>0;--i){
			if ( a[i] < b[i]){
				Left[i] = a[i]-b[i];
				if ( Left[i+1] < 0) Left[i] += Left[i+1];
			}
			else{
				Left[i] = a[i] - b[i] + Left[i+1];
			}
		}

		Left2[0] = totalfuel = totaldistance = 0 ;
		a[0]=a[n];
		b[0]=b[n];
		for( int i=1;i<=n;++i){
			if ( max(- Left2[i-1] ,(long long int)(0)) + totalfuel - totaldistance + a[i-1] >= b[i-1]){
				Left2[i] = Left2[i-1];
			}
			else{
				Left2[i] = -  (totaldistance + b[i-1] - a[i-1] - totalfuel );
			}
			//		cout << i << " "<< Left2[i] << endl;
			totaldistance += b[i-1];
			totalfuel += a[i-1];
		}
		if ( iter == 1){
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && Left[i]+Left2[i]>=0) canstart[i]=true;
			}
		}
		else{
			for(int i=1;i<=n;++i){
				if( Left[i]>=0 && Left[i]+Left2[i]>=0) canstart[n-i+1]=true;
			}
		}
		//		pr();
	}
	int k=0;
	for(int i=1;i<=n;++i) {
		if (canstart[i])++k;
	}
	cout << k << endl;
	for(int i=1;i<=n;++i){
		if ( canstart[i] ){
			printf("%d",i);
			k--;
			if ( k)printf(" ");
		}
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

#define inp_s     ios_base::sync_with_stdio(false)
#define DRT()     int test_case;cin>>test_case;while(test_case--)

#define VI        vector<int>
#define VS        vector<string>
#define VLL       vector<LL>
#define PII       pair<int,int>
#define all(c)    c.begin(),c.end()
#define sz(c)     (int)c.size()
#define clr(c)    c.clear()
#define pb        push_back
#define mp        make_pair

#define cin(x)     scanf("%d",&x)

#define FOR(i,a,b)      for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b)     for(int i=(int)(b)-1;i>=(int)(a);i--)

#define MOD       1000000007
#define EPS       1E-10

#define PI  acos(-1)

#define CASE(x)   cout << "Case #" << x << ": ";

int segtree[1000000] = {0};
int arr[1000000] = {0};

void buildTree(int l , int r , int pos)
{
    if(l == r)
    {
        segtree[pos] = arr[l];
        return ;
    }
    int mid = (l + r) / 2;
    buildTree(l , mid , 2*pos);
    buildTree(mid + 1 , r , 2 * pos + 1);
    segtree[pos] = min(segtree[2*pos] , segtree[2*pos + 1]);
}

int query(int lQ , int rQ , int l , int r , int pos)
{
    if(l > r or l > rQ or r < lQ) return INT_MAX;
    if(l >= lQ && r <= rQ) return segtree[pos];
    int mid = (l + r) / 2;
    return min(query(lQ,rQ,l,mid,2*pos) , query(lQ,rQ,mid+1,r,2*pos+1));
}

int a[1000000] = {0};
int b[1000000] = {0};

int main()
{
    inp_s;
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    for(int i = 1; i <= n; i++) arr[i] = a[i] - b[i];
    for(int i = n + 1; i <= 2*n; i++) arr[i] = arr[i-n];
    for(int i = 1; i <= 2*n; i++) arr[i] += arr[i-1];
    buildTree(1 , 2 * n , 1);

    set<int> poss;
    for(int i = 1; i <= n; i++)
    {
        int rmq = query(i , i + n , 1 , 2 * n , 1);
        if(rmq >= arr[i-1])
        {
            poss.insert(i);
        }
    }
    b[0] = b[n];
    FOR(i,1,n + 1) arr[i] = a[i] - b[i-1];
    FOR(i,n+1,2*n + 1) arr[i] = arr[i-n];
    for(int i = 2*n; i >= 1; i--) arr[i] += arr[i+1];
    buildTree(1 , 2*n , 1);
    for(int i = n + 1; i <= 2*n; i++)
    {
        int rmq = query(i - n , i , 1 , 2 * n , 1);
        if(rmq >= arr[i + 1])
        {
            poss.insert(i - n);
        }
    }
    cout << sz(poss) << endl;
    for(set<int>::iterator ii = poss.begin(); ii != poss.end(); ii++)
        cout << (*ii) << " ";
    cout << endl;
    return 0;
}


#include <iostream>

using namespace std;

typedef long long ll;

#define MAXN 524288
#define center(x, y) (x + y) >> 1
#define left(x) (x << 1) + 1
ll st[MAXN], add[MAXN];
int N;

ll C[MAXN];

/*
void stbuild(int idx = 0, int l = 0, int r = n - 1) {
  int L = left(idx), R = L + 1;
  if (l == r) {
    st[idx] = C[l];
    return;
  }
  int mid = center(l, r);
  stbuild(L, l, mid);
  stbuild(R, mid + 1, r);
  st[idx] = min(st[L], st[R]);
}

ll stq(int i, int j, int idx = 0, int l = 0, int r = N - 1) {
  int L = left(idx), R = L + 1;
  if (l >= i and r <= j)
    return st[idx];
  if (r < i or l > j)
    return 0;
  int mid = center(l, r);
  return min(stq(i, j, L, l, mid), stq(i, j, R, mid+1, r));
}
*/

ll A[MAXN], B[MAXN];
bool valid[MAXN];

int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  N = 2 * n;
  for (int i = 0; i < MAXN; ++i)
    st[i] = 1LL << 62;
  for (int i = 0; i < n; ++i)
    cin >> A[i];
  for (int i = 0; i < n; ++i)
    cin >> B[i];
  ll ac = 0, bc = 0;
  // clockwise
  ll mini = (1LL << 62);
  for (int i = 0; i < n; ++i) {
    ac += A[i];
    bc += B[i];
    mini = min(mini, ac-bc);
  }
  for (int i = 0; i < n; ++i) {
    valid[i] = mini >= 0;
    mini -= A[i]-B[i];
  }
  // counter clockwise
  mini = (1LL << 62);
  ac = bc = 0;
  for (int i = 0; i < n; ++i) {
    ac += A[n-i-1];
    bc += B[(n-i-2+n)%n];
    mini = min(mini, ac-bc);
  }
  for (int i = 0; i < n; ++i) {
    valid[n-i-1] |= mini >= 0;
    mini -= A[n-i-1] - B[(n-i-2+n)%n];
  }
  bool first = true;
  int ans = 0;
  for (int i = 0; i < n; ++i)
    ans += valid[i];
  cout << ans << endl;
  for (int i = 0; i < n; ++i)
    if (valid[i]) {
      if (not first)
        cout<< " ";
      cout << i+1;
      first = false;
    }
  cout << endl;
}


#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cmath>

using namespace std;

// Begin of MCMF

#define MAX_V 2003
#define MAX_E 1000000
typedef int cap_type;
typedef double cost_type;
const cost_type INF = 1e100;

int V,E,prev[MAX_V],last[MAX_V],to[MAX_E],next[MAX_E];
bool visited[MAX_V];
cap_type flowVal, cap[MAX_E];
cost_type flowCost,cost[MAX_E],dist[MAX_V],pot[MAX_V];

void init(int _V){
    memset(last,-1,sizeof(last));
    V = _V; E = 0;
}

void add_edge(int u, int v, cap_type _cap = 1, cost_type _cost = 0){
    to[E] = v, cap[E] = _cap;
    cost[E] = _cost, next[E] = last[u];
    last[u] = E++;
    to[E] = u, cap[E] = 0;
    cost[E] = -_cost, next[E] = last[v];
    last[v] = E++;
}

// only if there is initial negative cycle
void BellmanFord(int s, int t){
    bool stop = false;
    for(int i = 0;i<V;++i) dist[i] = INF;
    dist[s] = 0;

    for(int i = 1;i<=V && !stop;++i){
        stop = true;

        for(int j = 0;j<E;++j){
            int u = to[j^1], v = to[j];

            if(cap[j]>0 && dist[u]!=INF && dist[u]+cost[j]<dist[v]){
                stop = false;
                dist[v] = dist[u]+cost[j];
            }
        }
    }

    for(int i = 0;i<V;++i) if (dist[i]!=INF) pot[i] = dist[i];
}

void mcmf(int s, int t){
    flowVal = flowCost = 0;
    memset(pot,0,sizeof(pot));

    BellmanFord(s,t);

    while(true){
        memset(prev,-1,sizeof(prev));
        memset(visited,false,sizeof(visited));
        for(int i = 0;i<V;++i) dist[i] = INF;

        priority_queue< pair<cost_type, int> > Q;
        Q.push(make_pair(0,s));
        dist[s] = prev[s] = 0;

        while(!Q.empty()){
            int aux = Q.top().second;
            Q.pop();

            if(visited[aux]) continue;
            visited[aux] = true;

            for(int e = last[aux];e!=-1;e = next[e]){
                if(cap[e]<=0) continue;
                cost_type new_dist = dist[aux]+cost[e]+pot[aux]-pot[to[e]];
                if(new_dist<dist[to[e]]){
                    dist[to[e]] = new_dist;
                    prev[to[e]] = e;
                    Q.push(make_pair(-new_dist,to[e]));
                }
            }
        }

        if (prev[t]==-1) break;

        cap_type f = cap[prev[t]];
        for(int i = t;i!=s;i = to[prev[i]^1]) f = min(f,cap[prev[i]]);
        for(int i = t;i!=s;i = to[prev[i]^1]){
            cap[prev[i]] -= f;
            cap[prev[i]^1] += f;
        }

        flowVal += f;
        flowCost += f*(dist[t]-pot[s]+pot[t]);

        for(int i = 0;i<V;++i) if (prev[i]!=-1) pot[i] += dist[i];
    }
}

// End of MCMF

typedef pair<int, int> pii;
pii P[401];

double hipo(int i, int j) {
  int dx = P[i].first - P[j].first, dy = P[i].second - P[j].second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int n;
  scanf("%d", &n);
  init(2*n+2);
  for (int i = 0; i < n ; i++)
    scanf("%d %d", &P[i].first, &P[i].second);
  for (int i = 0; i < n; i++) {
    add_edge(0, i+1, 2);
    for (int j = 0; j < n; j++)
      if (P[i].second > P[j].second)
        add_edge(i+1, j + n + 1, 1, hipo(i, j));
    add_edge(i+n+1, 2*n+1);
  }
  mcmf(0, 2*n+1);
  if (flowVal == n - 1)
    printf("%.7f\n", flowCost);
  else
    puts("-1");
}


#include <iostream>

using namespace std;

typedef long long ll;

#define MAXN 524288
#define center(x, y) (x + y) >> 1
#define left(x) (x << 1) + 1
ll st[MAXN], add[MAXN];
int N;

ll C[MAXN];

/*
void stbuild(int idx = 0, int l = 0, int r = n - 1) {
  int L = left(idx), R = L + 1;
  if (l == r) {
    st[idx] = C[l];
    return;
  }
  int mid = center(l, r);
  stbuild(L, l, mid);
  stbuild(R, mid + 1, r);
  st[idx] = min(st[L], st[R]);
}

ll stq(int i, int j, int idx = 0, int l = 0, int r = N - 1) {
  int L = left(idx), R = L + 1;
  if (l >= i and r <= j)
    return st[idx];
  if (r < i or l > j)
    return 0;
  int mid = center(l, r);
  return min(stq(i, j, L, l, mid), stq(i, j, R, mid+1, r));
}
*/

ll A[MAXN], B[MAXN];
bool valid[MAXN];

int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  N = 2 * n;
  for (int i = 0; i < MAXN; ++i)
    st[i] = 1LL << 62;
  for (int i = 0; i < n; ++i)
    cin >> A[i];
  for (int i = 0; i < n; ++i)
    cin >> B[i];
  ll ac = 0, bc = 0;
  // clockwise
  ll mini = (1LL << 62);
  for (int i = 0; i < n; ++i) {
    ac += A[i];
    bc += B[i];
    mini = min(mini, ac-bc);
  }
  for (int i = 0; i < n; ++i) {
    valid[i] = mini >= 0;
    mini -= A[i]-B[i];
  }
  // counter clockwise
  mini = (1LL << 62);
  ac = bc = 0;
  for (int i = 0; i < n; ++i) {
    ac += A[n-i-1];
    bc += B[(n-i-2+n)%n];
    mini = min(mini, ac-bc);
  }
  for (int i = 0; i < n; ++i) {
    valid[n-i-1] |= mini >= 0;
    mini -= A[n-i-1] - B[(n-i-2+n)%n];
  }
  bool first = true;
  for (int i = 0; i < n; ++i)
    if (valid[i]) {
      if (not first)
        cout<< " ";
      cout << i+1;
      first = false;
    }
  cout << endl;
}


#include <iostream>
#include <cassert>

using namespace std;

typedef long long ll;

#define MAXN 100001

ll A[MAXN], B[MAXN];
bool valid[MAXN];

int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> A[i];
  for (int i = 0; i < n; ++i)
    cin >> B[i];
  ll ac = 0, bc = 0;
  // clockwise
  ll mini = (1LL << 62);
  for (int i = 0; i < n; ++i) {
    ac += A[i];
    bc += B[i];
    mini = min(mini, ac-bc);
  }
  for (int i = 0; i < n; ++i) {
    valid[i] = mini >= 0;
    mini -= A[i]-B[i];
  }
  // counter clockwise
  mini = (1LL << 62);
  ac = bc = 0;
  for (int i = 0; i < n; ++i) {
    ac += A[n-i-1];
    bc += B[(n-i-2+n)%n];
    mini = min(mini, ac-bc);
  }
  for (int i = 0; i < n; ++i) {
    assert(mini <= 0);
    valid[n-i-1] |= mini >= 0;
    mini -= A[n-i-1] - B[(n-i-2+n)%n];
  }
  bool first = true;
  int ans = 0;
  for (int i = 0; i < n; ++i)
    ans += valid[i];
  cout << ans << endl;
  for (int i = 0; i < n; ++i)
    if (valid[i]) {
      if (not first)
        cout<< " ";
      cout << i+1;
      first = false;
    }
  cout << endl;
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int mx = 10100;

int fuel[mx], dist[mx], sums[mx * 2];
bool ok[mx];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> fuel[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> dist[i];
	}
	for (int it = 0; it < 2; ++it) {
		sums[0] = 0;
		for (int i = 0; i < 2 * n; ++i) {
			sums[i + 1] = sums[i] + fuel[i % n] - dist[i % n];
		}
		int r = 1;
		multiset<int> srt;
		for (int i = 0; i < n; ++i) {
			while (srt.size() < n) {
				srt.insert(sums[r++]);
			}
			if (*srt.begin() >= sums[i]) {
				ok[i] = true;
			}
			srt.erase(srt.find(sums[i + 1]));
		}
		reverse(fuel, fuel + n);
		reverse(dist, dist + n);
		rotate(dist, dist + 1, dist + n);
		reverse(ok, ok + n);
	}
	vector<int> v;
	for (int i = 0; i < n; ++i) {
		if (ok[i]) {
			v.push_back(i);
		}
	}
	cout << v.size() << '\n';
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i] + 1 << ' ';
	}
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int mx = 100100;

int fuel[mx], dist[mx], sums[mx * 2];
bool ok[mx];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> fuel[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> dist[i];
	}
	for (int it = 0; it < 2; ++it) {
		sums[0] = 0;
		for (int i = 0; i < 2 * n; ++i) {
			sums[i + 1] = sums[i] + fuel[i % n] - dist[i % n];
		}
		int r = 1;
		multiset<int> srt;
		for (int i = 0; i < n; ++i) {
			while (srt.size() < n) {
				srt.insert(sums[r++]);
			}
			if (*srt.begin() >= sums[i]) {
				ok[i] = true;
			}
			srt.erase(srt.find(sums[i + 1]));
		}
		reverse(fuel, fuel + n);
		reverse(dist, dist + n);
		rotate(dist, dist + 1, dist + n);
		reverse(ok, ok + n);
	}
	vector<int> v;
	for (int i = 0; i < n; ++i) {
		if (ok[i]) {
			v.push_back(i);
		}
	}
	cout << v.size() << '\n';
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i] + 1 << ' ';
	}
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[200010],b[200010],c[200010],f[200010],g[200010];
bool flag[200010];
void calc()
{
    for (int i=n+1;i<=n<<1;i++)
    {
        a[i]=a[i-n];
        b[i]=b[i-n];
        c[i]=c[i-n];
    }
    for (int i=1;i<=n<<1;i++)
    {
        f[i]=f[i-1]+a[i];
        g[i]=g[i-1]+b[i];
    }
    for (int i=1,j=1;i<=n;i++)
    {
        while (j-i+1<n && f[j]-f[i-1]>=g[j]-g[i-1])
            j++;
        if (j-i+1==n)
            flag[c[i]]=true;
    }
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for (int i=1;i<=n;i++)
        c[i]=i;
    calc();
    reverse(a+1,a+n+1);
    reverse(b+1,b+n+1);
    reverse(c+1,c+n+1);
    rotate(a+1,a+n,a+n+1);
    rotate(c+1,c+n,c+n+1);
    calc();
    printf("%d\n",count(flag+1,flag+n+1,true));
    bool first=true;
    for (int i=1;i<=n;i++)
        if (flag[i])
        {
            if (!first)
                printf(" ");
            first=false;
            printf("%d",i);
        }
    printf("\n");
    return(0);
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[200010],b[200010],c[200010],f[200010],g[200010];
bool flag[200010];
void calc(bool state)
{
    for (int i=n+1;i<=n<<1;i++)
    {
        a[i]=a[i-n];
        b[i]=b[i-n];
        c[i]=c[i-n];
    }
    for (int i=1;i<=n<<1;i++)
    {
        f[i]=f[i-1]+a[i];
        g[i]=g[i-1]+b[i];
    }
    for (int i=1,j=1;i<=n;i++)
    {
        while (j-i+1<n && f[j]-f[i-1]>=g[j]-g[i-1])
            j++;
        if (j-i+1==n)
            flag[c[i]]=true;
    }
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for (int i=1;i<=n;i++)
        c[i]=i;
    calc(true);
    reverse(a+1,a+n+1);
    reverse(b+1,b+n+1);
    reverse(c+1,c+n+1);
    rotate(a+1,a+n,a+n+1);
    rotate(c+1,c+n,c+n+1);
    calc(false);
    printf("%d\n",count(flag+1,flag+n+1,true));
    bool first=true;
    for (int i=1;i<=n;i++)
        if (flag[i])
        {
            if (!first)
                printf(" ");
            first=false;
            printf("%d",i);
        }
    printf("\n");
    return(0);
}


#include <cstdio>
#include <vector>

using namespace std;

int a[100000],d[100000][2];

int main() {
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++)
        scanf("%d",&a[i]);
    for (int i=0; i<n; i++)
        scanf("%d",&d[i][1]);
    d[0][0]=d[n-1][1];
    for (int i=1; i<n; i++)
        d[i][0]=d[i-1][1];
    vector<int> res;
    for (int i=0; i<n; i++) {
        bool can=false;
        for (int j=0; j<2; j++) {
            int A=0,p=i,rc=1;
            while (rc<=n) {
                A+=a[p];
                if (A>=d[p][j]) {
                    A-=d[p][j];
                    if (j==0) {
                        if (p==0)
                            p=n-1;
                        else
                            p--;
                    } else {
                        if (p==(n-1))
                            p=0;
                        else
                            p++;
                    }
                    rc++;
                } else
                    break;
            }
            if (rc>n) {
                can=true;
                break;
            }
        }
        if (can)
            res.push_back(i+1);
    }
    printf("%d\n",res.size());
    if (!res.empty()) {
        printf("%d",res[0]);
        for (unsigned int i=1; i<res.size(); i++)
            printf(" %d",res[i]);
        printf("\n");
    }
    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int kMaxN = 1 << 17;

bool valid[kMaxN];

int sum(int i, int j, const vector<int> &partial) {
  if (i <= j)
    return partial[j] - partial[i];
  else
    return partial.back() - sum(j, i, partial);
}

inline int dec(int a, int n) { return a == 1 ? n : a - 1; }

inline int map(int pos, int N, bool shifted) {
  return !shifted || pos == 1 ? pos : N - pos + 2;
}

void solve(int N, const vector<int> &a, const vector<int> &b, bool shifted) {
  vector<int> partial(N + 2);
  int start = 1, min_partial = 0;
  for (int i = 1; i <= N; ++i) {
    partial[i + 1] = partial[i] + a[i] - b[i];
    if (partial[i + 1] < min_partial) {
      min_partial = partial[i + 1];
      start = i + 1;
    }
  }
  valid[map(start, N, shifted)] = true;
  int cur = dec(start, N), last = start;
  while (cur != start) {
    if (sum(cur, last, partial) >= 0) {
      valid[map(cur, N, shifted)] = true;
      last = cur;
    }
    cur = dec(cur, N);
  }
}

void shift(int N, vector<int> &a, vector<int> &b) {
  int i = 1, j = N;
  while (i < j) {
    std::swap(b[i], b[j]);
    ++i; --j;
  }
  i = 2, j = N;
  while (i < j) {
    std::swap(a[i], a[j]);
    ++i; --j;
  }
}

int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n + 1);
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  for (int i = 1; i <= n; ++i)
    cin >> b[i];
  solve(n, a, b, false);
  shift(n, a, b);
  solve(n, a, b, true);
  const int num_valid = count(valid, valid + n + 1, true);
  cout << num_valid << endl;
  for (int i = 1; i <= n; ++i)
    if (valid[i])
      cout << i << ' ';
  cout << endl;
  return 0;
}


// partial sums, greedy, observations, range minimum queries, cyclic array
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int kMaxN = 1 << 17;

bool valid[kMaxN];

inline int sum(int i, int j, const vector<int> &partial) {
  if (i <= j)
    return partial[j] - partial[i];
  else
    return partial.back() - sum(j, i, partial);
}

inline int map(int pos, int N, bool shifted) {
  return !shifted || pos == 1 ? pos : N - pos + 2;
}

void solve(int N, const vector<int> &a, const vector<int> &b, bool shifted) {
  vector<int> partial(N + 2);
  int start = 1, min_partial = 0;
  for (int i = 1; i <= N; ++i) {
    partial[i + 1] = partial[i] + a[i] - b[i];
    if (partial[i + 1] < min_partial)
      min_partial = partial[i + 1];
  }
  for (int i = 1; i <= N; ++i)
    if (partial[i] == min_partial)
      valid[map(i, N, shifted)] = true;
}

void shift(int N, vector<int> &a, vector<int> &b) {
  int i = 1, j = N;
  while (i < j) {
    std::swap(b[i], b[j]);
    ++i; --j;
  }
  i = 2, j = N;
  while (i < j) {
    std::swap(a[i], a[j]);
    ++i; --j;
  }
}

int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n + 1);
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  for (int i = 1; i <= n; ++i)
    cin >> b[i];
  solve(n, a, b, false);
  shift(n, a, b);
  solve(n, a, b, true);
  const int num_valid = count(valid, valid + n + 1, true);
  cout << num_valid << endl;
  for (int i = 1; i <= n; ++i)
    if (valid[i])
      cout << i << ' ';
  cout << endl;
  return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
using namespace std;

#define mp make_pair
#define pb push_back
#define snuke(it,x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it ++)
typedef long long lld;
typedef pair<int,int> PII;

const int N = 101000;
int n,z[N],a[N],b[N];
set<int> Set;

int main() {
        scanf("%d",&n);
        for (int i = 0; i < n; i ++) {
                scanf("%d",&a[i]);
        }
        for (int i = 0; i < n; i ++) {
                scanf("%d",&b[i]);
        }
        vector<int> ans;
        for (int i = 0; i < n; i ++) {
                z[i] = a[i]-b[i];
                if (i) z[i] += z[i-1];
                Set.insert(z[i]);
        }
        int line = 0;
        for (int i = 0; i < n; i ++) {
                if (*Set.begin()>=line) {
                        ans.pb(i+1);
                }
                line = z[i];
        }
        line = 0;
        Set.clear();
        for (int i = n-1; i >= 0; i --) {
                z[i] = a[i]-b[(i+n-1)%n];
                if (i!=n-1) z[i] += z[i+1];
                Set.insert(z[i]);
        }
        for (int i = n-1; i >= 0; i --) {
                if (*Set.begin()>=line) {
                        ans.pb(i+1);
                }
                line = z[i];
        }
        sort(ans.begin(),ans.end());
        ans.erase(unique(ans.begin(),ans.end()),ans.end());
        printf("%d\n",(int)ans.size());
        snuke(it,ans) {
                printf("%d ",*it);
        }
        puts("");
        return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
using namespace std;

#define mp make_pair
#define pb push_back
#define snuke(it,x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it ++)
typedef long long lld;
typedef pair<int,int> PII;

const int N = 101000;
int n,z[N],a[N],b[N];
set<PII> Set;

int main() {
        scanf("%d",&n);
        for (int i = 0; i < n; i ++) {
                scanf("%d",&a[i]);
        }
        for (int i = 0; i < n; i ++) {
                scanf("%d",&b[i]);
        }
        vector<int> ans;
        for (int i = 0; i < n; i ++) {
                z[i] = a[i]-b[i];
                if (i) z[i] += z[i-1];
                Set.insert(mp(z[i],i));
        }
        int line = 0;
        for (int i = 0; i < n; i ++) {
                if (Set.begin()->first>=line) {
                        ans.pb(i+1);
                }
                Set.erase(mp(z[i],i));
                Set.insert(mp(z[n-1]+z[i],i));
                line = z[i];
        }
        line = 0;
        Set.clear();
        for (int i = n-1; i >= 0; i --) {
                z[i] = a[i]-b[(i+n-1)%n];
                if (i!=n-1) z[i] += z[i+1];
                Set.insert(mp(z[i],i));
        }
        for (int i = n-1; i >= 0; i --) {
                if (Set.begin()->first>=line) {
                        ans.pb(i+1);
                }
                Set.erase(mp(z[i],i));
                Set.insert(mp(z[0]+z[i],i));
                line = z[i];
        }
        sort(ans.begin(),ans.end());
        ans.erase(unique(ans.begin(),ans.end()),ans.end());
        printf("%d\n",(int)ans.size());
        snuke(it,ans) {
                printf("%d ",*it);
        }
        puts("");
        return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <complex>

using namespace std;

typedef long long ll;

const ll inf = (ll)1e17;

bool can1[100100], can2[100100];
int a[100100], b[100100], lst[100100];
ll sum[100100], s[100100], val[100100];

int main(){
	//freopen("tea.in", "r", stdin);
	//freopen("tea.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 1; i <= n; i++){
		scanf("%d", &b[i]);
	}
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + b[i];
	}
	for(int i = 1; i <= n; i++){
		s[i] = s[i - 1] + a[i];
	}
	for(int i = 1; i <= n; i++){
		can1[i] = true;
	}
	val[n + 1] = -inf;
	for(int i = n; i > 0; i--){
		val[i] = max(val[i + 1], sum[i - 1] - s[i - 1]);
	}
	for(int i = 1; i <= n; i++){
		if(val[i + 1] > sum[i - 1] - s[i - 1]){
			can1[i] = false;
		}
	}
	val[0] = -inf;
	for(int i = 1; i <= n; i++){
		val[i] = max(val[i - 1], sum[i - 1] - s[i - 1]);
	}
	for(int i = 1; i <= n; i++){
		if(val[i] > sum[i - 1] - s[i - 1] - sum[n] + s[n]){
			can1[i] = false;
		}
	}
	for(int i = 1; i <= n; i++){
		can2[i] = true;
	}
	val[0] = inf;
	for(int i = 1; i <= n; i++){
		val[i] = min(val[i - 1], sum[i - 1] - s[i]);
	}
	for(int i = 1; i <= n; i++){
		if(sum[i - 1] - s[i] > val[i - 1]){
			can2[i] = false;
		}
	}
	val[n + 1] = inf;
	for(int i = n; i > 0; i--){
		val[i] = min(val[i + 1], sum[i - 1] - s[i]);
	}
	for(int i = 1; i <= n; i++){
		if(sum[i - 1] - s[i] + sum[n] - s[n] > val[i]){
			can2[i] = false;
		}
	}
	int sz = 0;
	for(int i = 1; i <= n; i++){
		if(can1[i] || can2[i]){
			lst[sz++] = i;
		}
	}
	printf("%d\n", sz);
	if(sz > 0){
		for(int i = 0; i < sz; i++){
			if(i > 0){
				printf(" ");
			}
			printf("%d", lst[i]);
		}
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <complex>

using namespace std;

typedef long long ll;

const ll inf = (ll)1e17;

bool can1[100100], can2[100100];
int a[100100], b[100100], lst[100100];
ll sum[100100], s[100100], val[100100];

int main(){
	//freopen("tea.in", "r", stdin);
	//freopen("tea.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 1; i <= n; i++){
		scanf("%d", &b[i]);
	}
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + b[i];
	}
	for(int i = 1; i <= n; i++){
		s[i] = s[i - 1] + a[i];
	}
	for(int i = 1; i <= n; i++){
		can1[i] = true;
	}
	val[n + 1] = -inf;
	for(int i = n; i > 0; i--){
		val[i] = max(val[i + 1], sum[i - 1] - s[i - 1]);
	}
	for(int i = 1; i <= n; i++){
		if(val[i + 1] > sum[i - 1] - s[i - 1]){
			can1[i] = false;
		}
	}
	val[0] = -inf;
	for(int i = 1; i <= n; i++){
		val[i] = max(val[i - 1], sum[i - 1] - s[i - 1]);
	}
	for(int i = 1; i <= n; i++){
		if(val[i] > sum[i - 1] - s[i - 1] - sum[n] + s[n]){
			can1[i] = false;
		}
	}
	for(int i = 1; i <= n; i++){
		can2[i] = true;
	}
	val[0] = inf;
	for(int i = 1; i <= n; i++){
		val[i] = min(val[i - 1], sum[i] - s[i]);
	}
	for(int i = 1; i <= n; i++){
		if(sum[i - 1] - s[i] > val[i - 1]){
			can2[i] = false;
		}
	}
	val[n + 1] = inf;
	for(int i = n; i > 0; i--){
		val[i] = min(val[i + 1], sum[i - 1] - s[i]);
	}
	for(int i = 1; i <= n; i++){
		if(sum[i - 1] - s[i] + sum[n] - s[n] > val[i]){
			can2[i] = false;
		}
	}
	int sz = 0;
	for(int i = 1; i <= n; i++){
		if(can1[i] || can2[i]){
			lst[sz++] = i;
		}
	}
	printf("%d\n", sz);
	if(sz > 0){
		for(int i = 0; i < sz; i++){
			if(i > 0){
				printf(" ");
			}
			printf("%d", lst[i]);
		}
		printf("\n");
	}
	return 0;
}


/*
 ID: ahaigh11
 PROG: codeforces beta round #61 C petya and post
 URL: http://www.codeforces.com/contest/66/problem/C
 LANG: C++

 */
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define CL(x) memset(x, 0, sizeof(x))

#define N 1005
#define M 400
#define inf (1<<30) //high enough?
#define eps (1e-10)

int n, a[N], b[N], def[N], fwd[N], bwd[N], fwd_min[M], gap, c;
bool can_use[N];

int rmq(int a, int b) { //incl.
	int a_gap = (a-1)/gap + 1, b_gap = (b+1)/gap - 1, best = inf;
	if (a_gap >= b_gap) {
		for (int i = a; i <= b; i++) best = min(best, fwd[i]);
		return best;
	}

	//cout << a_gap << " " << b_gap << endl;

	for (int i = a; i < a_gap*gap; i++) best = min(best, fwd[i]);
	for (int i = a_gap; i <= b_gap; i++) best = min(best, fwd_min[i]);
	for (int i = (b_gap+1)*gap; i <= b; i++) best = min(best, fwd[i]);
	return best;
}

int solve(bool flag) {
	fwd[0] = def[0]; for(int i = 1; i < n; i++) fwd[i] = fwd[i-1] + def[i];

	//REP(i, n) fwd[i] = n-i;

	gap = (int)(sqrt(n) + eps);
	for (int i = 0; i*gap < n; i++) {
		fwd_min[i] = inf;
		for (int k = i*gap; k < (i+1)*gap; k++) fwd_min[i] = min(fwd_min[i], fwd[k]);
	}

	int w[N], v[N];
	w[0] = 0; REP(i, n) if (i) w[i] = min(w[i-1], fwd[i-1]);
	v[n-1] = fwd[n-1]; for(int i = n-2; i >= 0; i--) v[i] = min(v[i+1], fwd[i]);

	REP(i, n) {
		//can go ---> if fwd[n-1] - fwd[i-1] = total fuel lost getting to the edge
		//+ min(fwd[0] ... fwd[i-1]) >= 0
		//cout << i << " " << rmq(i, n-1) << " " << fwd[i] << " " << fwd[n-1] - fwd[i-1] << " " << min(0, i-1) << endl;

		//cout << i << " " << def[i] << " " << fwd[i] << " " << v[i] << " " << (fwd[n-1] - fwd[i-1]) << " " << w[i] << endl;
		if (v[i] - fwd[i-1] >= 0 && (fwd[n-1] - fwd[i-1] + w[i]) >= 0) {

			int j = i;
			if (flag) j = (n - i) % n;
			//cout << i << endl;
			if (!can_use[j]) {
				can_use[j] = true;
				//cout << "#" << j << endl;
				c++;
			}
		}
	}
}

int main() {
	scanf("%d",&n);
	REP(i, n) scanf("%d",&a[i]);
	REP(i, n) scanf("%d",&b[i]);

	CL(can_use); c = 0;
	REP(i, n) def[i] = a[i] - b[i]; solve(false);
	REP(i, n) def[i] = a[(n-i)%n] - b[(n-1-i)%n]; solve(true);

	cout << c << endl;
	REP(i, n) if (can_use[i]) cout << (i+1) << " "; cout << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define rep(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define mmm(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<x<<'\n'
const LL mod=998244353;
const int maxn=1e6+9;
const int inf=0x3f3f3f3f;
LL rd(){ LL ans=0; char last=' ',ch=getchar();
    while(!(ch>='0' && ch<='9'))last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans; return ans;
}
#define rd rd()

int n,k,l;
char x[maxn];
LL ans;

#define pill pair<LL, int>
pill dp[maxn];
pill check(LL C){
    dp[0]={0,0};
    rep(i,1,n){
        dp[i]=dp[i-1];
        dp[i].first+=x[i];
        if(i<=l)dp[i]=min(dp[i],{C,1});
        else dp[i]=min(dp[i],{dp[i-l].first+C,dp[i-l].second+1});
    }
    return dp[n];
}

LL ANS=2e18;
void deal(){
    LL l=0,r=n,ans;
    while(l<=r){
        LL mid=l+r>>1;
        if(check(mid).second<=k)ans=mid,r=mid-1;
        else l=mid+1;
    }
    pill res=check(ans);
    ANS=min(ANS,res.first-ans*k);//is k not res.second
}

int main(){
    n=rd,k=rd,l=rd;
    scanf("%s",x+1);
    rep(i,1,n){
        if(islower(x[i]))x[i]=0;
        else x[i]=1;
    }
    deal();
    rep(i,1,n)x[i]=1-x[i];
    deal();
    printf("%lld\n",ANS);
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n:0);
	vector<ll>d(n);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	ll ans=0;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	return all/n-(dp[n].fi-(n+dp[n].se*l)*m)/n;
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?s[i]-'a'+'A':s[i]-'A'+'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*2:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
	if(-dp[n].se<k&&m>0)
	{
		vector<pl>dp(n+1,pl(0,0));
		ll m=ss-1;
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		ll a2=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
		ll T=-dp[n].se;
		ans=((T-k)*ans+(k-t)*a2+T-t-1)/(T-t);
	}
	return ans;
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*4:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*4;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all/n/l/4-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/4;
	if(-dp[n].se<k&&m>0)
	{
		vector<pl>dp(n+1,pl(0,0));
		ll m=ss-1;
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		ll a2=all/n/l/4-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/4;
		ll T=-dp[n].se;
		ans=((T-k)*ans+(k-t)*a2+T-t-1)/(T-t);
	}
	return ans;
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*2:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all-(dp[n].fi-(n+dp[n].se*l)*m);
	return ans/n/l/2-(k+dp[n].se)*m/(n*2);
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
ll n,k,l;
ll solve(string s)
{
	ll all=0;
	ll i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*2:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all-(dp[n].fi-(n+dp[n].se*l)*m);
	return ans/n/l/2-(k+dp[n].se)*m/(n*2);
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*2:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
	if(-dp[n].se<k&&m>0)
	{
		vector<pl>dp(n+1,pl(0,0));
		ll m=ss-1;
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		ll a2=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
		ll T=-dp[n].se;
		ans=((T-k)*ans+(k-t)*a2+T-t+1)/(T-t);
	}
	return ans;
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*2:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
	if(-dp[n].se<k&&m>0)
	{
		vector<pl>dp(n+1,pl(0,0));
		ll m=ss-1;
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		ll a2=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
		ll T=-dp[n].se;
		ans=((T-l)*ans+(l-t)*a2)/(T-t);
	}
	return ans;
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*2:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
	if(-dp[n].se<k&&m>0)
	{
		vector<pl>dp(n+1,pl(0,0));
		ll m=ss-1;
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		ll a2=all/n/l/2-(dp[n].fi-(n+dp[n].se*l)*m)/n/l/2;
		ll T=-dp[n].se;
		ans=((T-l)*ans+(l-t)*a2+T-t-1)/(T-t);
	}
	return ans;
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,k,l;
ll solve(string s)
{
	ll all=0;
	int i;
	vector<ll>v(n,0);
	for(i=0;i<n;i++)
		all+=(v[i]=s[i]>='a'?n*l*2:0);
	vector<ll>d(n,0);
	for(i=0;i<l;i++)
		d[0]+=v[i];
	for(i=0;i++<n-l;)
		d[i]=d[i-1]+v[i+l-1]-v[i-1];
	ll ss=0;
	ll ee=l*n*2;
	while(ss<ee)
	{
		ll m=ss+ee>>1;
		vector<pl>dp(n+1,pl(0,0));
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		if(-dp[n].se<=k)
			ee=m;
		else
			ss=m+1;
	}
	vector<pl>dp(n+1,pl(0,0));
	ll m=ss;
	for(i=0;i<n;i++)
	{
		if(i<=n-l)
			dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
		dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
	}
	ll t=-dp[n].se;
	ll ans=all-(dp[n].fi-(n+dp[n].se*l)*m);
	if(-dp[n].se<k&&m>0)
	{
		vector<pl>dp(n+1,pl(0,0));
		ll m=ss-1;
		for(i=0;i<n;i++)
		{
			if(i<=n-l)
				dp[i+l]=max(dp[i+l],pl(dp[i].fi+d[i],dp[i].se-1));
			dp[i+1]=max(pl(dp[i].fi+m,dp[i].se),dp[i+1]);
		}
		ll a2=all-(dp[n].fi-(n+dp[n].se*l)*m);
		ll T=-dp[n].se;
		ans=((T-k)*ans+(k-t)*a2+T-t-1)/(T-t);
	}
	return ans/n/l/2;
}
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin>>n>>k>>l;
	if((ll)k*l>=n)
		return cout<<0<<endl,0;
	cin>>s;
	ll ans=solve(s);
	for(int i=0;i<n;i++)
		s[i]=s[i]>='a'?'A':'a';
	cout<<min(solve(s),ans);
    return 0;
}


//in the name of GOD
#include <bits/stdc++.h>
#define pb push_back
# define S second
# define F first
# define ll long long
# define ld long double
using namespace std;
typedef pair < ll, ll > pii;
typedef pair < ll , pii > piii;
typedef pair < ld , ld > point ;
//setprecision(8)
//freopen("chip.in","r",stdin);freopen("chip.out","w",stdout);
const int maxn = 1e6 + 100 ;
int n , l , k , a[maxn] , Ans ;
string s ;
int dp[maxn] , cnt[maxn] ;
int solve(int cost)
{
	memset(dp,0,sizeof dp) ;
	memset(cnt , 0, sizeof cnt) ;
	for(int y = 1 ; y <= n ; y++)
	{
		dp[y] = dp[y-1]+a[y] ; cnt[y] = cnt[y-1] ;
		if(dp[max(0,y-l)]+cost<dp[y])
		dp[y] = cost+dp[max(0,y-l)] , cnt[y] = cnt[y-l]+1 ;
	}
	return cnt[n] ;
}
int Bs(int i ,int j)
{
	if(i+1==j)
	return j ;
	int md = (i+j)>>1 ;
	if(solve(md)>k)
	return Bs(md,j);
	else
	return Bs(i,md);
}
int main(){
	cin>>n>>k>>l>>s;
	Ans = n ;
	for(int y = 1 ; y <= n ; y++)
		a[y] = (s[y-1]<'a') ;
	solve(Bs(-1,n+2)) ;
	Ans = min(Ans , dp[n]-k*cnt[n]) ;
	for(int y = 1 ; y <= n ; y++)
		a[y] ^= 1 ;
	solve(Bs(-1,n+2)) ;
	Ans = min(Ans , dp[n]-k*cnt[n]) ;
	cout<<Ans ;
	return 0 ;
}


//in the name of GOD
#include <bits/stdc++.h>
#define pb push_back
# define S second
# define F first
# define ll long long
# define ld long double
using namespace std;
typedef pair < ll, ll > pii;
typedef pair < ll , pii > piii;
typedef pair < ld , ld > point ;
//setprecision(8)
//freopen("chip.in","r",stdin);freopen("chip.out","w",stdout);
const int maxn = 1e6 + 100 ;
int n , l , k , a[maxn] , Ans ;
string s ;
int dp[maxn] , cnt[maxn] ;
int solve(int cost)
{
	memset(dp,0,sizeof dp) ;
	memset(cnt , 0, sizeof cnt) ;
	for(int y = 1 ; y <= n ; y++)
	{
		dp[y] = dp[y-1]+a[y] ; cnt[y] = cnt[y-1] ;
		if(dp[max(0,y-l)]+cost<dp[y])
		dp[y] = cost+dp[max(0,y-l)] , cnt[y] = cnt[max(0,y-l)]+1 ;
	}
	return cnt[n] ;
}
int Bs(int i ,int j)
{
	if(i+1==j)
	return j ;
	int md = (i+j)>>1 ;
	if(solve(md)>k)
	return Bs(md,j);
	else
	return Bs(i,md);
}
int main(){
	cin>>n>>k>>l>>s;
	Ans = n ;
	for(int y = 1 ; y <= n ; y++)
		a[y] = (s[y-1]<'a') ;
	int po ;
	po = Bs(-1,n+2) ;
	solve(po) ;
	Ans = min(Ans , dp[n]-k*po) ;
	for(int y = 1 ; y <= n ; y++)
		a[y] ^= 1 ;
	po = Bs(-1,n+2) ;
	solve(po) ;
	Ans = min(Ans , dp[n]-k*po) ;
	cout<<Ans ;
	return 0 ;
}


// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

pair<ll,ll> test(vector<int> &a, int cost, int l){
	int n = sz(a);
	vector< pair<ll,ll> > dp(n+1);
	dp[0] = {0,0};
	for(int i = 1; i <= n; ++i){
		dp[i] = {dp[i-1].fst + a[i-1], dp[i-1].snd};
		if(i >= l) dp[i] = min(dp[i], {dp[i-l].fst + cost, dp[i-l].snd + 1});
		else dp[i] = min(dp[i], {cost,1});
	}
	return dp[n];
}

int solve(vector<int> a, int k, int l){
	int lo = -1, hi = 1e9;
	while(hi - lo > 1){
		int mid = (lo + hi) / 2;
		if(test(a,mid,l).snd <= k) hi = mid;
		else lo = mid;
	}
	auto ans = test(a,hi,l);
	return ans.fst - k * hi;
}

int main(){

	fastio;
	int n,k,l;
	cin >> n >> k >> l;
	vector<int> a(n);
	string s;
	cin >> s;
	for(int i = 0; i < n; ++i){
		a[i] = (s[i] >= 'A' && s[i] <= 'Z');
	}
	int ans = solve(a,k,l);
	for(int i = 0; i < n; ++i){
		a[i] = 1 - a[i];
	}
	ans = min(ans, solve(a,k,l));
	cout << ans << endl;

	return 0;
}


// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define endl '\n'
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

pair<ll,ll> test(vector<int> &a, int cost, int l){
	int n = sz(a);
	vector< pair<ll,ll> > dp(n+1);
	dp[0] = {0,0};
	for(int i = 1; i <= n; ++i){
		dp[i] = {dp[i-1].fst + a[i-1], dp[i-1].snd};
		if(i >= l) dp[i] = min(dp[i], {dp[i-l].fst + cost, dp[i-l].snd + 1});
	}
	return dp[n];
}

int solve(vector<int> a, int k, int l){
	int lo = -1, hi = 1e9;
	while(hi - lo > 1){
		int mid = (lo + hi) / 2;
		//cout << "lo = " << lo << " hi = " << hi << endl;
		if(test(a,mid,l).snd <= k) hi = mid;
		else lo = mid;
	}
	auto ans = test(a,hi,l);
	return ans.fst - k * hi;
}

int main(){

	fastio;
	int n,k,l;
	cin >> n >> k >> l;
	vector<int> a(n);
	string s;
	cin >> s;
	for(int i = 0; i < n; ++i){
		a[i] = (s[i] >= 'A' && s[i] <= 'Z');
	}
	int ans = solve(a,k,l);
	for(int i = 0; i < n; ++i){
		a[i] = 1 - a[i];
	}
	ans = min(ans, solve(a,k,l));
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

const int maxn = 1e6 + 7;
string s;
int n, k, l, a[maxn], ans = 1e8;
pair<int, int> dp[maxn];
pair<int, int> cal(int cost)
{
    for(int i = 1; i <= n; i++)
    {
        dp[i] = dp[i - 1];
        dp[i].first += a[i];
        if(i >= l) dp[i] = min(dp[i], make_pair(dp[i - l].first + cost, dp[i - l].second + 1));
    }
    return dp[n];
}

void Solve()
{
    int l = 0, r = ::l;
    while(l <= r)
    {
        int mid = l + r >> 1;
        if(cal(mid).second > k) l = mid + 1;
        else r = mid - 1;
    }
    ans = min(ans, cal(l).first - k * l);
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r" ,stdin), freopen("test.out", "w", stdout);
    cin >> n >> k >> l >> s;
    if(l * k >= n) return cout << 0, 0;
    s = ' ' + s;
    for(int i = 1; i <= n; i++)
    {
        a[i] = (s[i] >= 'a' && s[i] <= 'z');
    }
    Solve();
    for(int i = 1; i <= n; i++)
    {
        a[i] = (s[i] >= 'A' && s[i] <= 'Z');
    }
    Solve();
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int N = 1e6 + 7;
const double EPS = 1e-4;

bool v[N];
int n, k, l;
int s[N];

pair < double, int > dp[N];

int optimal(double lambda) {
    for (int i = 1; i <= l; ++i) {
        if (s[i] < lambda)
            dp[i] = {s[i], 0};
        else
            dp[i] = {lambda, 1};
    }
    for (int i = l + 1; i <= n; ++i) {
        if (v[i] + dp[i - 1].first < lambda + dp[i - l].first)
            dp[i] = {v[i] + dp[i - 1].first, dp[i - 1].second};
        else
            dp[i] = {lambda + dp[i - l].first, dp[i - l].second + 1};
    }
    return dp[n].second;
}

int solve() {
    for (int i = 1; i <= n; ++i)
        s[i] = s[i - 1] + v[i];
    double pas = 5e5 + 7, r(0);
    while (pas > EPS) {
        if (optimal(r + pas) >= k)
            r += pas;
        if (dp[n].second == k)
            break;
        pas /= 2;
    }
    return (dp[n].first - r * k);
}

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k >> l;
    char ch;
    int ans(1e9 + 7);
    for (int i = 1; i <= n; ++i)
        cin >> ch, v[i] = (ch >= 'A' && ch <= 'Z');
    ans = solve();
    for (int i = 1; i <= n; ++i)
        v[i] = 1 - v[i];
    ans = min(ans, solve());
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int N = 1e6 + 7;
const double EPS = 1e-6;

bool v[N];
int n, k, l;
int s[N];

pair < double, int > dp[N];

int optimal(double lambda) {
    for (int i = 1; i <= l; ++i) {
        if (s[i] < lambda)
            dp[i] = {s[i], 0};
        else
            dp[i] = {lambda, 1};
    }
    for (int i = l + 1; i <= n; ++i) {
        if (v[i] + dp[i - 1].first < lambda + dp[i - l].first)
            dp[i] = {v[i] + dp[i - 1].first, dp[i - 1].second};
        else
            dp[i] = {lambda + dp[i - l].first, dp[i - l].second + 1};
    }
    return dp[n].second;
}

int solve() {
    for (int i = 1; i <= n; ++i)
        s[i] = s[i - 1] + v[i];
    double pas = 5e7 + 7, r(0);
    while (pas > EPS) {
        if (optimal(r + pas) >= k)
            r += pas;
        if (dp[n].second == k)
            break;
        pas /= 2;
    }
    double ans = dp[n].first - r * k;
    if (ans - (int)ans > 1.0/2)
        return (int)ans + 1;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k >> l;
    char ch;
    int ans(1e9 + 7);
    for (int i = 1; i <= n; ++i)
        cin >> ch, v[i] = (ch >= 'A' && ch <= 'Z');
    ans = solve();
    for (int i = 1; i <= n; ++i)
        v[i] = 1 - v[i];
    ans = min(ans, solve());
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int N = 1e6 + 7;
const double EPS = 1e-4;

bool v[N];
int n, k, l;
int s[N];

pair < double, int > dp[N];

int optimal(double lambda) {
    for (int i = 1; i <= l; ++i) {
        if (s[i] < lambda)
            dp[i] = {s[i], 0};
        else
            dp[i] = {lambda, 1};
    }
    for (int i = l + 1; i <= n; ++i) {
        if (v[i] + dp[i - 1].first < lambda + dp[i - l].first)
            dp[i] = {v[i] + dp[i - 1].first, dp[i - 1].second};
        else
            dp[i] = {lambda + dp[i - l].first, dp[i - l].second + 1};
    }
    return dp[n].second;
}

int solve() {
    for (int i = 1; i <= n; ++i)
        s[i] = s[i - 1] + v[i];
    double pas = 5e6 + 7, r(0);
    while (pas > EPS) {
        if (optimal(r + pas) >= k)
            r += pas;
        if (dp[n].second == k)
            break;
        pas /= 2;
    }
    double ans = dp[n].first - r * k;
    if (ans - (int)ans > 1.0/2)
        return (int)ans + 1;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k >> l;
    char ch;
    int ans(1e9 + 7);
    for (int i = 1; i <= n; ++i)
        cin >> ch, v[i] = (ch >= 'A' && ch <= 'Z');
    ans = solve();
    for (int i = 1; i <= n; ++i)
        v[i] = 1 - v[i];
    ans = min(ans, solve());
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int N = 1e6 + 7;
const double EPS = 1e-4;

bool v[N];
int n, k, l;
int s[N];

pair < double, int > dp[N];

int optimal(double lambda) {
    for (int i = 1; i <= l; ++i) {
        if (s[i] < lambda)
            dp[i] = {s[i], 0};
        else
            dp[i] = {lambda, 1};
    }
    for (int i = l + 1; i <= n; ++i) {
        if (v[i] + dp[i - 1].first < lambda + dp[i - l].first)
            dp[i] = {v[i] + dp[i - 1].first, dp[i - 1].second};
        else
            dp[i] = {lambda + dp[i - l].first, dp[i - l].second + 1};
    }
    return dp[n].second;
}

int solve() {
    for (int i = 1; i <= n; ++i)
        s[i] = s[i - 1] + v[i];
    double pas = 5e5 + 7, r(0);
    while (pas > EPS) {
        if (optimal(r + pas) >= k)
            r += pas;
        if (dp[n].second == k)
            break;
        pas /= 2;
    }
    double ans = dp[n].first - r * k;
    if (ans - (int)ans > 1.0/2)
        return (int)ans + 1;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k >> l;
    char ch;
    int ans(1e9 + 7);
    for (int i = 1; i <= n; ++i)
        cin >> ch, v[i] = (ch >= 'A' && ch <= 'Z');
    ans = solve();
    for (int i = 1; i <= n; ++i)
        v[i] = 1 - v[i];
    ans = min(ans, solve());
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

int solve(){
 	int n,k,l;cin>>n>>k>>l;
 	string s;cin>>s;
 	vector<int>a(n+1);
 	int ans=n;
 	auto func=[&](int x){
 		vector<pii>dp(n+1,{1e9,0});
 		dp[0].x=0;
 		for(int i=0;i<n;i++){
 			if(dp[i+1]>make_pair(dp[i].x+a[i],dp[i].y)){
 				dp[i+1]=make_pair(dp[i].x+a[i],dp[i].y);
 			}
 			if(dp[min(i+l,n)]>make_pair(dp[i].x+x,dp[i].y+1)){
 				dp[min(i+l,n)]=make_pair(dp[i].x+x,dp[i].y+1);
 			}
 		}
 		return dp[n];

 	};
 	auto solve=[&](){
 		int L=0,R=n+1;
 		int c=0;
 		while(L<=R){
 			int M=(L+R)/2;
 			pii p=func(M);
 			if(p.y>k){
 				L=M+1;
 				c=M;
 			}
 			else{
 				R=M-1;
 			}
 		}
 		pii p=func(c);
 		if(p.y<=k)return 0LL;
 		p=func(c+1);
 		return p.x-k*(c+1);

 	};
 	for(int i=0;i<n;i++){
 		a[i]=isupper(s[i])>0;
 	}
 	mins(ans,solve());
 	for(int i=0;i<n;i++){
 		a[i]=islower(s[i])>0;
 	}
 	mins(ans,solve());
 	cout<<ans<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <iostream>
#include <string>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, k, l;
string s;
llint a[1000005], sum[1000005];
P dp[1000005];

P calc(llint x)
{
	for(int i = 1; i <= n; i++) dp[i] = P(inf, inf);
	dp[0] = P(0LL, 0LL);

	for(int i = 0; i < n; i++){
		dp[i+1] = min(dp[i+1], dp[i]);
		llint r = min(i+l, n);
		dp[r] = min(dp[r], P(dp[i].first-(sum[r]-sum[i])+x, dp[i].second+1) );
	}
	dp[n].first += min(0LL, k*x);
	return dp[n];
}

llint solve()
{
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
	//for(int i = 1; i <= n; i++) cout << a[i]; cout << endl;

	llint ub = 1e13, lb = -1e13, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		P res = calc(mid);
		if(res.second <= k) ub = mid;
		else lb = mid;
		//cout << mid << " " << res.first << " " << res.second << endl;
	}

	P res = calc(ub);
	//cout << ub << " " << res.first << " " << res.second << endl;

	llint ret = res.first - k * ub;
	ret += sum[n];
	//cout << ret << endl;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> k >> l;
	cin >> s;
	s = "#" + s;

	for(int i = 1; i <= n; i++){
		if(s[i] >= 'a') a[i] = 1;
		else a[i] = 0;
	}
	llint ans = solve();

	for(int i = 1; i <= n; i++){
		if(s[i] >= 'a') a[i] = 0;
		else a[i] = 1;
	}
	ans = min(ans, solve());

	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <string>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, k, l;
string s;
llint a[1000005], sum[1000005];
P dp[1000005];

P calc(llint x)
{
	for(int i = 1; i <= n; i++) dp[i] = P(inf, inf);
	dp[0] = P(0LL, 0LL);

	for(int i = 0; i < n; i++){
		dp[i+1] = min(dp[i+1], dp[i]);
		llint r = min(i+l, n);
		dp[r] = min(dp[r], P(dp[i].first-(sum[r]-sum[i])+x, dp[i].second+1) );
	}
	dp[n].first += min(0LL, k*x);
	return dp[n];
}

llint solve()
{
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
	//for(int i = 1; i <= n; i++) cout << a[i]; cout << endl;

	llint ub = 1e13, lb = -1e13, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		P res = calc(mid);
		if(res.second <= k) ub = mid;
		else lb = mid;
		//cout << mid << " " << res.first << " " << res.second << endl;
	}

	P res = calc(ub);
	//cout << ub << " " << res.first << " " << res.second << endl;

	llint ret = res.first - k * ub;
	ret += sum[n];
	//cout << ret << endl;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> k >> l;
	cin >> s;
	s = "#" + s;

	if((n+l-1)/l <= k){
		cout << 0 << endl;
		return 0;
	}

	for(int i = 1; i <= n; i++){
		if(s[i] >= 'a') a[i] = 1;
		else a[i] = 0;
	}
	llint ans = solve();

	for(int i = 1; i <= n; i++){
		if(s[i] >= 'a') a[i] = 0;
		else a[i] = 1;
	}
	ans = min(ans, solve());

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using piii = pair<int, pii>;
using plll = pair<ll, pll>;
using pib = pair<int, bool>;
using pdi = pair<double, int>;
using pid = pair<int, double>;
using ld = long double;
using piiii = pair<pii, pii>;

#define endl "\n"
#define inf 0x3f3f3f3f3f
#define f first
#define s second

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int n, k, l;
ll psa[1000001], cnt[1000001];
ld dp[1000001];
string s;

bool f(ld v1, int c1, ld v2, int c2){
    if (abs(v1-v2)<=1e-10) return c1<c2;
    return v1>v2;
}

bool check(ld c){
    memset(cnt, 0, sizeof cnt);
    for (int i=1; i<=n; i++){
        dp[i] = dp[i-1];
        cnt[i] = cnt[i-1];
        if (i<l){
            if (f(psa[i]-c, 1, dp[i], cnt[i])){
                dp[i] = psa[i]-c;
                cnt[i] = 1;
            }
        }else{
            if (f(psa[i]-psa[i-l]-c+dp[i-l], cnt[i-l]+1, dp[i], cnt[i])){
                dp[i] = psa[i]-psa[i-l]-c+dp[i-l];
                cnt[i] = cnt[i-l]+1;
            }
        }
    }
    return cnt[n]<=k;
}

int main() {
    //freopen("cowmbat.in", "r", stdin);
    //freopen("cowmbat.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k >> l >> s;
    for (int i=1; i<=n; i++){
        if (s[i-1]<='z'&&s[i-1]>='a') psa[i] = 1;
        psa[i] += psa[i-1];
    }
    ll ans = 1e18;
    ld lo = 0;
    ld hi = 1e6;
    while (hi-lo>1e-10){
        ld mid = (lo+hi)/2;
        if (check(mid)) {
            hi = mid;
        }
        else lo = mid;
    }
    ans = min(ans, (ll) (psa[n]-round(dp[n]+hi*k)));
    for (int i=1; i<=n; i++){
        if (s[i-1]<='Z'&&s[i-1]>='A') psa[i] = 1;
        else psa[i] = 0;
        psa[i] += psa[i-1];
    }
    lo = 0;
    hi = 1e6;
    while (hi-lo>1e-10){
        ld mid = (lo+hi)/2;
        if (check(mid)){
            hi = mid;
        }
        else lo = mid;
    }
    ans = min(ans, (ll) (psa[n]-round(dp[n]+hi*k)));
    cout << ans << endl;
    return 0;
}