#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main()
{
int n,k1,k2,k3,l=0,r=0;
scanf("%d %d %d %d",&n,&k1,&k2,&k3);
int a[n],h4[n],r5[n],r8[n];
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
h4[i]=a[i]%4;
r5[i]=a[i]%5;
r8[i]=a[i]%8;
}
for(int i=0; i<n-1; i++)
{
int l2=0,r2=0;
if(abs(h4[i]-h4[i+1])<=k1 && abs(r5[i]-r5[i+1])<=k2 && abs(r8[i]-r8[i+1])<=k3)
{
l2=i+1;
while (true)
{
i++;
if(abs(h4[i]-h4[i+1])>k1 || abs(r5[i]-r5[i+1])>k2 || abs(r8[i]-r8[i+1])>k3)
break;
}
r2=i+1;
}
if(i==n-1)
{
if(h4[i]<=k1 && r5[i]<=k2 && r8[i]<=k3)
{
r2++;
}
}
if(r2-l2>r-l)
{
l=l2;
r=r2;
}
}
printf("%d %d", l,r);
}
Copy