#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
#define LINF 100000000000000000
#define INF 1000000000
const int N = 1e6+10;
const LL MOD = 1e9+7;
int a[N][3];
int k[3];
int nxtzero[N][3],val[N][3];
int main()
{
//freopen("out.txt","w",stdout);
int n;
scanf("%d",&n);
for(int i=0;i<3;i++)
scanf("%d",&k[i]);
for(int i=1;i<=n;i++){
int x;scanf("%d",&x);
a[i][0] = x%4;
a[i][1] = x%5;
a[i][2] = x%8;
}
for(int i=2;i<=n;i++){
for(int j=0;j<3;j++)
val[i][j] = abs(a[i][j]-a[i-1][j])<=k[j];
}
int last[3] = {n,n,n};
int ans = 0,l,r;
for(int i=n;i>=1;i--){
int mn = min({last[0],last[1],last[2]});
if(mn-i+1>ans)ans = mn-i+1,l = i,r = mn;
for(int j=0;j<3;j++)
if(!val[i][j])last[j] = i-1;
}
printf("%d %d\n",l,r);
}
Copy