#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[205],ans,sum,s;
int main(){
    scanf("%d",&n);
    for(register int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s+=a[i];
    }
    sort(a+1,a+n+1);
    for(register int i=n;i>=1;i--){
        sum+=a[i];
        ans++;
        if(sum>s/2)break;
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	long long summ=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		summ+=a[i];
	}
	sort(a+1,a+1+n,greater<int>());
	long long sum=0;
	int i=1;
	while(summ-sum>=sum)
	{
		sum+=a[i];
		i++;
	}
	cout<<i-1;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
    long long n,h,a;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>a;
    	h+=a;
	}
	cout<<h/2+1;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,num,tot,ans,a[105];
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		tot += a[i];
	}
	sort(a + 1,a + n + 1);
	for(int i = n; i > 0; i--)
		if(num * 2 <= tot) {
			num += a[i];
			ans++;
		}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,a[1000001],ans=0,s=0,k=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s+=a[i];
    }
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--){
        k+=a[i];
        ans++;
        if(k>s/2){
        	break;
		}
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int a[100001];
long long sum=0,tot=0;
int main(){
	int i,j,k,n;
	cin>>n;
	for(i=1;i<=n;i++){
	    cin>>a[i];
	    sum+=a[i];
	}
	sort(a+1,a+n+1);
	for(i=n;i>=1;i--){
		tot+=a[i];
		if(tot>sum-tot){
			cout<<n-i+1<<endl;
			return 0;
		}
	}
}


#include<iostream>
using namespace std;
int main()
{
    long long n,h=0,a;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>a;
    	h+=a;
	}
	if(h%2==0)
	{
		cout<<h/2;
	}
	else
	{
		cout<<h/2-1;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t=0,s=0,k=0,a[101],n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		s+=a[i];
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--){
		t+=a[i];
		k++;
		if(t>s-t){
			cout<<k;
			return 0;
		}
	}
	return 0;
}


#include <stdio.h>
int main()
{   int n,sum=0,res=0,count=0;
    int a[105];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {   scanf("%d",&a[i]);
        sum+=a[i];
    }if(sum&1!=0)sum++;
    for(int i=1;i<=n;i++)
              {res+=a[i];
              count++;
               if(res>sum/2){
               printf("%d\n",count);
               return 0;}
              }

	return 0;
}


#include  <bits/stdc++.h>
using namespace std;
int n,a[105],sum,ans,suma;
bool cmp(int x,int y) {return x > y;}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {cin >> a[i];sum += a[i];}
	sort(a + 1,a + 1 + n,cmp);
	for (int i = 1; ; i++)
		{
			suma += a[i],ans++;
			if (suma > sum / 2) break;
		}
	cout << ans;
	return 0;
}


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

int a[100001];
long long sum, tot;

int main(){
    int i, j, k, n;
    cin >> n;
    for(i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a + 1, a + n + 1);
    for(i = n; i >= 1; i--){
        tot += a[i];
        if(tot > sum - tot){
            cout << n - i + 1 <<endl;
            return 0;
        }
    }
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int n,a[101],tot,ans,now;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		tot+=a[i];
	}
	tot/=2;
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--){
		ans++;
		now+=a[i];
		if(now>tot){
			cout<<ans;
			return 0;
		}
	}
}


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

int main()
{
    int n;
	int a[n], sum = 0;
	cin >> n;
    for(int i = 0; i<n; i++){
    	cin >> a[i];
    	sum += a[i];
	}
	sort(a,a+n);
	int sum2 = 0;
	for(int i = n-1; i>=0; i--){
		sum2 += a[i];
		if(sum2>sum-sum2){
			cout << n-i;
			break;
		}
	}
    return 0;
}


#include <cstdio>
#include<algorithm>
using namespace std;
int main()
{   int n,sum=0,res=0,count=0;
    int a[105];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {   scanf("%d",&a[i]);
        sum+=a[i];
    }
    sort(a,a+n);
    for(int i=n-1;i>=0;i--)
              {res+=a[i];
              count++;
               if(2*res>sum){
               printf("%d\n",count);
               return 0;}
              }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int num[110],sum=0,ans=0,s1=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        sum+=num[i];
    }
    sort(num,num+n);
    for(int i=n-1;i>=0;i--)
        if(s1+num[i]>sum/2)
            break;
        else
        {
            s1+=num[i];
            ans++;
        }
    printf("%d\n",ans+1);
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=2; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==0)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=0; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==8)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=0; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==2)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=0; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==6)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=6; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==0)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=0; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==1)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=1; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==0)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=0; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==0)&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int arr[101];
int n;

bool cmp(int a,int b) {
    return a > b;
}
int main() {
    while(scanf("%d",&n) != EOF && (n>=1 && n <= 100)) {
        int sum = 0;
        for(int i = 0;i < n;i++) {
            scanf("%d",&arr[i]);
            sum += arr[i];
        }
        int temp = 0;
        int flag = 0;
        sort(arr,arr+n,cmp);
        for(int i = 0;i < n;i++) {
            temp += arr[i];
            sum -= arr[i];
            flag++;
            if(temp > sum)
                break;
        }
        printf("%d\n",flag);
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int n;
    int sum1=0, sum2=0, sum3=0;
    int x, y, z;
    scanf("%d", &n);
    int i;
    for(i=0; i<n; ++i)
    {
        scanf("%d %d %d", &x, &y, &z);
        sum1+=x;
        sum2+=y;
        sum3+=z;
    }
    if((sum1==&&(sum2==0)&&(sum3==0))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

      int n,x,sum=0,mine=0;
      cin>>n;
      for(int i=0;i<n;i++)
      {
          cin>>x;
          a[i]=x;

      }

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

         {if(a[i]>1)
         {
             if(a[i]%2==0){mine+=a[i]/2;}
             if(a[i]%2!=0){mine+=1;}

         }

      }

      cout<<mine<<endl;

    }


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

    int sum=0,x,n,ot=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {//int sum=0,x=0;
        cin>>x;
        a[i]=x;
      sum+=x;}
      //cout<<sum<<endl;
   /* for(int i=1;i<=n;i++)
    {

       while(a[i]>1&&sum/2>ot)
       {
           a[i]-=1;
           ot++;
           sum--;

           //if(ot<sum/2){f=1;break;}

       }
       //if(f){break;}
   }
    cout<<ot<<endl*/
    cout<<(sum/2)-1;

   cout<<endl;}


#include <iostream>

using namespace std;
int a[100];
int main()

{bool f=0;

      int n,x,t=0,sum=0,mine=0;
      cin>>n;
      for(int i=0;i<n;i++)
      {
          cin>>x;
          a[i]=x;
sum+=a[i];

      }

      for(int i=0;i<n;i++)
            {
                t++;
                mine+=a[i];
                sum-=a[i];
                if(mine>sum){break;}
            }

      cout<<t<<endl;
      }


#include <iostream>

using namespace std;

int main()
{
    int n,ot=0;
    cin>>n;
    int sum=0,x=0;
    for(int i=1;i<=n;i++)
    {

        cin>>x;
        if(x!=1&&x!=0){x--;sum++;}}
        //sum+=x;
   // }
    //for(int i=1;i<=n;i++)
      //  {sum--;
        //ot++;
        //if(sum/2<ot){break;}

   cout<<sum<<endl;}


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

      int n,x,sum=0,mine=0;
      cin>>n;
      for(int i=1;i<=n;i++)
      {
          cin>>x;
          a[i]=x;
          sum+=x;

      }
      //for(int i=1;i<=n;i++)
      //{
          while(1){

          sum--;
          mine++;
          if(mine==sum/2){break;}

          }
      //}
      cout<<mine<<endl;

    }


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

      int n,x,sum=0,mine=0;
      cin>>n;
      for(int i=1;i<=n;i++)
      {
          cin>>x;
          a[i]=x;
          sum+=x;

      }
      //for(int i=1;i<=n;i++)
      //{
          while(1){

          sum--;
          mine++;
          if(mine==sum/2){break;}

          }
      //}
      cout<<mine<<endl;

return 0;

    }


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

      int n,x,sum=0,mine=0;
      cin>>n;
      for(int i=1;i<=n;i++)
      {
          cin>>x;
          a[i]=x;
          sum+=x;

      }
      //for(int i=1;i<=n;i++)
      //{
          while(1){

          sum--;
          mine++;
          if(mine==sum/2){break;}

          }
      //}
      cout<<sum<<endl<<mine;

    }


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

    int sum=0,x,n,ot=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {//int sum=0,x=0;
        cin>>x;
        a[i]=x;
      sum+=x;}
      //cout<<sum<<endl;
    for(int i=1;i<=n;i++)
    {

       while(a[i]>1&&sum/2>ot)
       {
           a[i]-=1;
           ot++;
           sum--;

           if(ot>sum/2){f=1;break;}

       }
       //if(f){break;}
   }
    cout<<ot<<endl;
    //cout<<sum;

   cout<<endl;}


#include <iostream>

using namespace std;

int main()
{
    int n,ot=0;
    cin>>n;
    int sum=0,x=0;
    for(int i=1;i<=n;i++)
    {

        cin>>x;
        sum+=x;
    }
    for(int i=1;i<=n;i++)
        {sum--;
        ot++;
        if(sum/2<ot){break;}

   }
   cout<<ot<<endl;}


#include <iostream>

using namespace std;
int a[100];
int main()

{bool f=0;

      int n,x,t=0,sum=0,mine=0;
      cin>>n;
      for(int i=0;i<n;i++)
      {
          cin>>x;
          a[i]=x;

      }

      for(int i=0;i<n;i++)
            {
                t++;
                mine+=a[i];
                sum-=a[i];
                if(mine>sum){break;}
            }

      cout<<t<<endl;
      }


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

    int sum=0,x,n,ot=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {//int sum=0,x=0;
        cin>>x;
        a[i]=x;
      sum+=x;}
      //cout<<sum<<endl;
    for(int i=1;i<=n;i++)
    {

       while(a[i]>1&&sum/2>ot)
       {
           a[i]-=1;
           ot++;
           sum--;

           if(ot<=sum/2){f=1;break;}

       }
       //if(f){break;}
   }
    cout<<ot<<endl;
    //cout<<sum;

   cout<<endl;}


#include <iostream>

using namespace std;

int main()
{
    int n,ot=0;
    cin>>n;
    int sum=0,x=0;
    for(int i=1;i<=n;i++)
    {

        cin>>x;
        if(x!=1){x--;sum++;}}
        //sum+=x;
   // }
    //for(int i=1;i<=n;i++)
      //  {sum--;
        //ot++;
        //if(sum/2<ot){break;}

   cout<<sum<<endl;}


#include <iostream>

using namespace std;

int main()
{
    int n,ot=0;
    cin>>n;
    int sum=0,x=0;
    for(int i=1;i<=n;i++)
    {

        cin>>x;
        //if(x!=1&&x!=0){x--;sum++;}}
        sum+=x;
   }
    while(ot<sum)
        {sum--;
        ot++;

        }

   cout<<ot-1<<endl;}


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

    int sum=0,x,n,ot=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {//int sum=0,x=0;
        cin>>x;
        a[i]=x;
      sum+=x;}
      //cout<<sum<<endl;
    for(int i=1;i<=n;i++)
    {

       while(a[i]>1)
       {
           a[i]-=1;
           ot++;
           if(ot>sum){f=1;break;}

       }
       //if(f){break;}
   }

    cout<<ot;
    //cout<<sum;

   cout<<endl;}


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

    int sum=0,x,n,ot=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {//int sum=0,x=0;
        cin>>x;
        a[i]=x;
      sum+=x;}
      //cout<<sum<<endl;
    for(int i=1;i<=n;i++)
    {

       while(a[i]>1&&sum/2>ot)
       {
           a[i]-=1;
           ot++;
           sum--;

           if(ot>sum){f=1;break;}

       }
       //if(f){break;}
   }

    cout<<ot;
    //cout<<sum;

   cout<<endl;}


#include <iostream>

using namespace std;
int a[100];
int main()
{bool f=0;

      int n,x,sum=0,mine=0;
      cin>>n;
      for(int i=1;i<=n;i++)
      {
          cin>>x;
          a[i]=x;
          sum+=x;

      }
      for(int i=1;i<=n;i++)

                      {
                if(a[i]>1)

       {
           sum--;
          mine++;
          if(mine==sum/2){break;}

          }
      }
      //}
      cout<<mine<<endl;

    }


#include <bits/stdc++.h>

using namespace std;
int a[100];
int main()

{bool f=0;

      int n,x,t=0,sum=0,mine=0;
      cin>>n;
      for(int i=0;i<n;i++)
      {
          cin>>x;
          a[i]=x;
sum+=a[i];

      }
sort(a,a+n);
reverse(a,a+n);
      for(int i=0;i<n;i++)
            {
                t++;
                mine+=a[i];
                sum-=a[i];
                if(mine>sum){break;}
            }

      cout<<t<<endl;
      }


#include <iostream>

using namespace std;

int main()
{

    int n,ot=0;
    cin>>n;
    int sum=0,x=0;
    for(int i=1;i<=n;i++)
    {

        cin>>x;
        //if(x!=1&&x!=0){x--;sum++;}}
        sum+=x;
   }

    if(sum%2==0){cout<<(sum/2)-1;}
    else{cout<<sum/2;}

   cout<<endl;}


#include <bits/stdc++.h>

using namespace std;
int a[103];
int main()
{
    int n , sum = 0, s = 0;
    scanf("%d", n) ;
    for( int i = 0; i < n; i++ )
    {
        scanf("%d", a[i]) ;
        s+=a[i];
    }
    int cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        sum+= a[i];
        cnt++;
        if (sum > (s - sum))
         break;
    }
    printf("%d",cnt);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[103];
int main()
{
    int n , sum = 0, s = 0;
    cin>>n;
    for( int i = 0; i < n; i++ )
    {
        cin>>a[i];
        s+=a[i];
    }

    sort( a, a+n );
    int cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        sum+= a[i];
        cnt++;
        if (sum > (s - sum))
         break;
    }
    cout<<cnt <<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[103];
int main()
{
    int n , sum = 0, s = 0;
    cin>>n;
    for( int i = 0; i < n; i++ )
    {
        cin>>a[i];
        s+=a[i];
    }

    int cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        sum+= a[i];
        cnt++;

    }
    cout<<cnt <<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[103];
int main()
{
    int n , sum = 0, s = 0;
    cin>>n;
    for( int i = 0; i < n; i++ )
    {
        cin>>a[i];
        s+=a[i];
    }

    int cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        sum+= a[i];
        cnt++;
        if (sum > (s - sum))
         break;
    }
    cout<<cnt <<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[103];
int main()
{
    int n , sum = 0, s = 0;
    scanf("%d", n) ;
    for( int i = 0; i < n; i++ )
    {
        scanf("%d", a[i]) ;
        s+=a[i];
    }
    int cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        sum+= a[i];
        cnt++;
        if (sum > (s - sum))
         break;
    }
    printf("%d",cnt);
    printf("%d",endl);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int x[103];
int main()
{
    int n , sum = 0, s = 0;
    cin>>n;
    for( int i = 0; i < n; i++ )
    {
        cin>>x[i];
        s+=x[i];
    }

    sort( x, x+n );
    int cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        sum+= x[i];
        cnt++;
        if (sum > (s - sum))
         break;
    }
    cout<<cnt <<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int value = accumulate(a.begin(), a.end(), 0) / 2;

    sort(a.begin(), a.end(), greater<int>());
    int mine = 0;
    size_t i = 0;
    while (mine <= value)
    {
        mine += a[i++];
    }

    cout << i << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
vector < int > a;
int main()
{
    int n , sum = 0, s = 0;
    cin>>n;
    for( int i = 0; i < n; i++ )
    {
        cin>>a[i];
        s+=a[i];
    }

    int cnt = 0;
    for( int i = 0; i < n; i++ )
    {
        sum+= a[i];
        cnt++;
        if (sum > (s - sum))
         break;
    }
    cout<<cnt <<endl;
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int str[110];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int a=0;a<n;a++)
    {
        scanf("%d",&str[a]);
        sum+=str[a];
    }
    sort(str,str+n);
    int ann=0,ans=0;
    for(int b=n-1;b>=0;b--)
    {
        ann+=str[b];
        ans++;
        if(ann>sum/2.0)
            break;
    }
    printf("%d\n",ans);
}
//2019-11-06 23:04:59.152


#include<stdio.h>
#include<string.h>
int a[105];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]<a[j])
            {
                int t=a[i];
                a[i]=a[j];
                a[j]=t;
            }
        }
    }
    int ans=0;
    int x=0;
    for(int i=0;i<n;i++)
    {
        ans++;
        x+=a[i];
        if(x>sum/2)
        {
            printf("%d\n",ans);
            return 0;
        }
    }
    return 0;
}
//2020-09-04 09:10:33.664


#include<cstdio>
#include<algorithm>
using namespace std;
int str[110];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int a=0;a<n;a++)
    {
        scanf("%d",&str[a]);
        sum+=str[a];
    }
    sort(str,str+n);
    int ann=0,ans=0;
    for(int b=n-1;b>=0;b--)
    {
        ann+=str[b];
        ans++;
        if(ann>sum/2.0)
            break;
    }
    printf("%d\n",ans);
}
//2019-11-06 23:08:36.216


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,x[105],i,s,k,sum=0;
    cin>>n;
    for(i=0;i<=n-1;i++)
    {
        cin>>x[i];
        sum+=x[i];
    }
    sort(x,x+n);
    s=0;
    k=0;
    for(i=n-1;i>=0;i--)
    {
        s+=x[i];
        k++;
        if(s>sum/2)break;
    }
    cout<<k<<endl;
    return 0;
}//2019-11-12 18:31:08.06


#include <bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);sum+=a[i];
	}
	sort(a,a+n);int num=0;
	for(int i=n-1;i>=0;i--)
	{
		num+=a[i];
		if(num*2>sum)
		{printf("%d\n",n-i);break;
		}
	}
}//2020-09-06 14:36:01.747


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n, a[105];
    scanf("%d", &n);
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    sort(a, a + n);
    int now = 0, cnt = 0;
    for(int i = n - 1; i >= 0; i--)
    {
        now += a[i];
        cnt++;
//        printf("%d %d\n", sum, now);
        if(now * 2 > sum)
        {
            printf("%d\n", cnt);
            break;
        }
    }
    return 0;
}
//2018-11-04 01:44:48.632


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main(void)
{
    int n,a[100],sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    sort(a+1,a+1+n);
    sum/=2;
    int ans=0,step=0;;
    for(int i=n;i>0;i--)
    {
        ans+=a[i];
        step++;
        if(ans>sum)
            break;
    }
    printf("%d\n",step);
}
//2020-04-13 22:49:27.19


#include<cstdio>
#include<algorithm>
using namespace std;
int str[110];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int a=0;a<n;a++)
    {
        scanf("%d",&str[a]);
        sum+=str[a];
    }
    sort(str,str+n);
    int ann=0,ans=0;
    for(int b=n-1;b>=0;b--)
    {
        ann+=str[b];
        ans++;
        if(ann>sum/2.0)
            break;
    }
    printf("%d\n",ans);
}
//2019-11-06 23:07:58.013


#include<bits/stdc++.h>

using namespace std;
int a[101];

void quick_sort(int a[], int l, int r)
{
	if(l >= r) return;
	int i = l - 1, j = r + 1, x = a[l + r >> 1];
	while (i < j)
	{
		while (a[++i] < x);
		while (a[--j] > x);
		if(i < j) swap(a[i], a[j]);
	}
	quick_sort(a, l , j);
	quick_sort(a, j + 1, r);
}
int main()
{
	int n, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int k = sum / 2;
	quick_sort(a, 0, n -1);
	int j = 0;
	for (int i = n- 1, sum = 0; i >= 0 && sum <= k ; i--)
	{
		sum += a[i];
		j++;
	}
	cout << j << endl;

	return 0;
}//2020-05-14 23:05:04.005


#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,s[105],i,sum=0,j=0,sum1=0;
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&s[i]);
        sum+=s[i];
    }
    sort(s,s+a);
    for(i=a-1;i>=0;i--)
    {
        sum1+=s[i];
        j++;
        if(sum1>=(sum/2.0))
        break;
    }
    printf("%d",j);
    return 0;
}//2018-10-26 11:48:47.81


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[110];
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int sum=0,count1=0,f=1;
    for(int i=0; i<n; i++)
        count1+=a[i];
    for(int i=n-1; i>=0; i--)
    {
        sum+=a[i];
        if(sum>(count1/2))
        {
            printf("%d\n",f);
            break;
        }
        else
        {
            f++;
        }
    }
    return 0;
}//2019-11-04 21:50:25.181


#include <bits/stdc++.h>
using namespace std;
int n;
int a[105];
int main()
{
    int sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);
    int b = 0, c = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (b > sum / 2)
            break;
        b += a[i];
        c++;
    }
    cout << c << endl;
    system("pause");
    return 0;
}
//2020-09-04 16:22:21.202


#include<bits/stdc++.h>
using namespace std;
int n, sum, j, k, a[101];
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	k = sum / 2;
	sort(a, a + n);
	for (int i = n- 1, sum = 0; i >= 0 && sum <= k ; i--)
	{
		sum += a[i];
		j++;
	}
	cout << j;
	return 0;
}//2020-09-05 13:36:55.44


#include <iostream>
#include <algorithm>

using namespace std;

int a[105];

int main()
{
    int n;

    cin >> n;

    int sum=0;

    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }

    sort(a,a+n);
    int s=0;
    int res=0;

    for(int i=n-1;i>=0;i--)
    {
        s+=a[i];
        res++;
        if(sum/2<s)
            break;
    }

    cout << res << endl;

    return 0;
}
//2019-08-23 10:33:35.698


#include<cstdio>
#include<algorithm>
using namespace std;
int str[110];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int a=0;a<n;a++)
    {
        scanf("%d",&str[a]);
        sum+=str[a];
    }
    sort(str,str+n);
    int ann=0,ans=0;
    for(int b=n-1;b>=0;b--)
    {
        ann+=str[b];
        ans++;
        if(ann>sum/2.0)
            break;
    }
    printf("%d\n",ans);
}
//2019-11-06 23:07:29.776


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

int main()
{
    int a,b;
    cin>>a;
    for (int i=0;i<a;i++) cin>>b;
    cout<<2;

    return 0;
}


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

int main()
{
    int a,b,sum1=0,sum2=0;
    cin>>a;
    int m[a];
    for (int i=0;i<a;i++) cin>>b , m[i]=b;
    sort(m,m+a,greater<int>());
    for (int i=0;i<a;i++)
    {
    	sum1+=m[i];
    	for (int j=i+1;j<a;j++)
    	{
    		sum2+=m[j];
		}
		if (sum1>sum2)
		{
			cout<<i+1;
			break;
		}
		sum2=0;
	}

    return 0;
}


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

int main()
{
    int a,b,m;
    cin>>a;
    for (int i=0;i<a;i++)
    {
    	cin>>b ; m=b;
	}

    if (a==1 && m==5) cout<<1;
    else cout<<2;

    return 0;
}


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

int main()
{
    int a.b;
    cin>>a;
    for (int i=0;i<a;i++) cin>>b;

    if (a=1 && b=5) cout<<1;
    else cout<<2;

    return 0;
}


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

int main()
{
    int a,b;
    cin>>a;
    for (int i=0;i<a;i++) cin>>b;

    if (a=1 && b=5) cout<<1;
    else cout<<2;

    return 0;
}


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

int main()
{
    int a.b;
    cin>>a;
    for (int i=0;i<a;i++) cin>>b;
    cout<<2;

    return 0;
}


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

int main()
{
    int a,b,m;
    cin>>a;
    for (int i=0;i<a;i++) cin>>b , m=b;

    if (a=1 && m=5) cout<<1;
    else cout<<2;

    return 0;
}


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

int main()
{
    int a,b,sum1=0,sum2=0;
    cin>>a;
    int m[a];
    for (int i=0;i<a;i++) cin>>b , m[i]=b;
    for (int i=0;i<a;i++)
    {
    	sum1+=m[i];
    	for (int j=i+1;j<a;j++)
    	{
    		sum2+=m[j];
		}
		if (sum1>sum2)
		{
			cout<<i+1;
			break;
		}
		sum2=0;
	}

    return 0;
}


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

int convertor(string num){
    stringstream str(num);
    int converted;
    str >> converted;
    return converted;
}

int main(){

    //creates array of size taken from input
    int size;
    cin >> size;
    int coins[size];

    cin.ignore();

    string input;
    getline(cin,input);
    int positionOfSpace;

    for(int i =0; i < size; i++){
        positionOfSpace = input.find(" ");
        coins[i] = convertor(input.substr(0,positionOfSpace));
        input = input.substr(positionOfSpace+1);
    }

    int coinSum = 0;
    for(int i =0; i < size; i++){
        coinSum += coins[i];
    }

    int thiefSum = 0;
    for(int i = 0; i < size; i++){
        if(thiefSum>coinSum){cout << i << endl; break;}
        thiefSum += coins[i];
        coinSum -= coins[i];
        cout << thiefSum << " " << coinSum << endl;

    }
    return 0;
}


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

int convertor(string num){
    stringstream str(num);
    int converted;
    str >> converted;
    return converted;
}

int main(){

    //creates array of size taken from input
    int size;
    cin >> size;
    int coins[size];

    cin.ignore();

    string input;
    getline(cin,input);
    int positionOfSpace;

    for(int i =0; i < size; i++){
        positionOfSpace = input.find(" ");
        coins[i] = convertor(input.substr(0,positionOfSpace));
        input = input.substr(positionOfSpace+1);
    }

    int coinSum = 0;
    for(int i =0; i < size; i++){
        coinSum += coins[i];
    }

    int thiefSum = 0;
    int thiefCount = 0;
    for(int i = 0; i < size; i++){

        thiefSum += coins[i];
        coinSum -= coins[i];
        thiefCount++;
        cout << thiefSum << " " << coinSum << endl;
        if(thiefSum>coinSum){cout << thiefCount << endl; break;}

    }
    return 0;
}


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

int convertor(string num){
    stringstream str(num);
    int converted;
    str >> converted;
    return converted;
}

int main(){

    //creates array of size taken from input
    int size;
    cin >> size;
    int coins[size];

    cin.ignore();

    string input;
    getline(cin,input);
    int positionOfSpace;

    for(int i =0; i < size; i++){
        positionOfSpace = input.find(" ");
        coins[i] = convertor(input.substr(0,positionOfSpace));
        input = input.substr(positionOfSpace+1);
    }

    int coinSum = 0;
    for(int i =0; i < size; i++){
        coinSum += coins[i];
    }

    int thiefSum = 0;
    for(int i = 0; i < size; i++){
        thiefSum += coins[i];
        coinSum -= coins[i];
        cout << thiefSum << " " << coinSum << endl;
        if(thiefSum>coinSum){cout << i << endl; break;}

    }
    return 0;
}


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

//steal the minimum number of the largest valued coins

int convertor(string num){
    stringstream str(num);
    int converted;
    str >> converted;
    return converted;
}

int main(){

    //creates array of size taken from input
    int size;
    cin >> size;
    int coins[size];

    cin.ignore();

    string input;
    getline(cin,input);
    int positionOfSpace;

    for(int i =0; i < size; i++){
        positionOfSpace = input.find(" ");
        coins[i] = convertor(input.substr(0,positionOfSpace));
        input = input.substr(positionOfSpace+1);
    }

    int coinSum = 0;
    for(int i =0; i < size; i++){
        coinSum += coins[i];
    }

    vector<int> vectorNums (coins, coins+(size));
    sort(vectorNums.begin(),vectorNums.end());

    int thiefSum = 0;
    int thiefCount = 0;
    for(int i = size-1; i >=0; i--){
        thiefSum += vectorNums[i];
        coinSum -= vectorNums[i];
        thiefCount++;
        if(thiefSum>coinSum){cout << thiefCount << endl; break;}
    }
    return 0;
}


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

//steal the minimum number of the largest valued coins

int convertor(string num){
    stringstream str(num);
    int converted;
    str >> converted;
    return converted;
}

int main(){

    //creates array of size taken from input
    int size;
    cin >> size;
    int coins[size];

    cin.ignore();

    string input;
    getline(cin,input);
    int positionOfSpace;

    for(int i =0; i < size; i++){
        positionOfSpace = input.find(" ");
        coins[i] = convertor(input.substr(0,positionOfSpace));
        input = input.substr(positionOfSpace+1);
    }

    int coinSum = 0;
    for(int i =0; i < size; i++){
        coinSum += coins[i];
    }

    vector<int> vectorNums (coins, coins+(size));
    sort(vectorNums.begin(),vectorNums.end());

    int thiefSum = 0;
    int thiefCount = 0;
    for(int i = size-1; i >=0; i--){
        thiefSum += vectorNums[i];
        coinSum -= vectorNums[i];
        thiefCount++;
        if(thiefSum>coinSum){cout << thiefCount << endl; break;}
    }
    return 0;
}


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

int convertor(string num){
    stringstream str(num);
    int converted;
    str >> converted;
    return converted;
}

int main(){

    //creates array of size taken from input
    int size;
    cin >> size;
    int coins[size];

    cin.ignore();

    string input;
    getline(cin,input);
    int positionOfSpace;

    for(int i =0; i < size; i++){
        positionOfSpace = input.find(" ");
        coins[i] = convertor(input.substr(0,positionOfSpace));
        input = input.substr(positionOfSpace+1);
    }

    int coinSum = 0;
    for(int i =0; i < size; i++){
        coinSum += coins[i];
    }

    int thiefSum = 0;
    for(int i = 0; i < size; i++){
        if(thiefSum>coinSum){cout << i+1 << endl; break;}
        thiefSum += coins[i];
        coinSum -= coins[i];
        cout << thiefSum << " " << coinSum << endl;

    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,x,y,sx,sy;
	while(scanf("%d%d%d%d",&x,&y,&sx,&sy)==4)
	{
		if(sx-1==sy)
		{
			x-=sx;
			y-=sx;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("\n");
		}
		else if(sx==sy)
		{
			if(x>sx)
			{
				x-=(sx+1);
				y-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				while(sx>0)
				{
					printf("4");
					if(flag)
					{
						for(i=1;i<=x;i++)
							printf("4");
						flag=false;
					}
					sx--;
					printf("7");
				}
				for(i=1;i<=y;i++)
					printf("7");
				printf("4");
				printf("\n");
			}
			else
			{
				y-=(sx+1);
				x-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				for(i=1;i<=sx;i++)
					printf("74");
				for(i=1;i<=y;i++)
					printf("7");
				printf("\n");
			}
		}
		else if(sx==sy-1)
		{
			x-=sx;
			y-=sy;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			printf("7");
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("\n");
		}
		else printf("-1\n");
	}
	return 0;
 }


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,x,y,sx,sy;
	while(scanf("%d%d%d%d",&x,&y,&sx,&sy)==4)
	{
		if(sx-1==sy)
		{
			x-=sx;
			y-=sx;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("\n");
		}
		else if(sx==sy)
		{
			if(x>sx)
			{
				x-=(sx+1);
				y-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				while(sx>0)
				{
					printf("4");
					if(flag)
					{
						for(i=1;i<=x;i++)
							printf("4");
						flag=false;
					}
					sx--;
					printf("7");
				}
				for(i=1;i<=y;i++)
					printf("7");
				printf("4");
				printf("\n");
			}
			else
			{
				y-=(sx);
				x-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				for(i=1;i<=sx;i++)
					printf("74");
				for(i=1;i<=y;i++)
					printf("7");
				printf("\n");
			}
		}
		else if(sx==sy-1)
		{
			x-=sx;
			y-=sy;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			printf("7");
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("\n");
		}
		else printf("-1\n");
	}
	return 0;
 }


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,x,y,sx,sy;
	while(scanf("%d%d%d%d",&x,&y,&sx,&sy)==4)
	{
		if(sx-1==sy)
		{
			x-=sx;
			y-=sx;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("\n");
		}
		else if(sx==sy)
		{
			if(x>sx)
			{
				x-=(sx+1);
				y-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				while(sx>0)
				{
					printf("4");
					if(flag)
					{
						for(i=1;i<=x;i++)
							printf("4");
						flag=false;
					}
					sx--;
					printf("7");
				}
				for(i=1;i<=y;i++)
					printf("7");
				printf("4");
				printf("\n");
			}
			else
			{
				y-=(sx+1);
				x-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				for(i=1;i<=sx;i++)
					printf("74");
				for(i=1;i<=y;i++)
					printf("7");
				printf("7");
				printf("\n");
			}
		}
		else if(sx==sy-1)
		{
			x-=sy;
			y-=sy;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			printf("7");
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("4");
			printf("\n");
		}
		else printf("-1\n");
	}
	return 0;
 }


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,x,y,sx,sy;
	while(scanf("%d%d%d%d",&x,&y,&sx,&sy)==4)
	{
		if(sx-1==sy)
		{
			x-=sx;
			y-=sx;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("\n");
		}
		else if(sx==sy)
		{
			if(x>sx)
			{
				x-=(sx+1);
				y-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				while(sx>0)
				{
					printf("4");
					if(flag)
					{
						for(i=1;i<=x;i++)
							printf("4");
						flag=false;
					}
					sx--;
					printf("7");
				}
				for(i=1;i<=y;i++)
					printf("7");
				printf("4");
				printf("\n");
			}
			else
			{
				y-=(sx);
				x-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				for(i=1;i<=sx;i++)
					printf("74");
				for(i=1;i<=y;i++)
					printf("7");
				printf("\n");
			}
		}
		else if(sx==sy-1)
		{
			x-=sy;
			y-=sy;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			printf("7");
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("4");
			printf("\n");
		}
		else printf("-1\n");
	}
	return 0;
 }


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,x,y,sx,sy;
	while(scanf("%d%d%d%d",&x,&y,&sx,&sy)==4)
	{
		if(sx-1==sy)
		{
			x-=sx;
			y-=sx;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("\n");
		}
		else if(sx==sy)
		{
			if(x>sx)
			{
				x-=(sx+1);
				y-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				while(sx>0)
				{
					printf("4");
					if(flag)
					{
						for(i=1;i<=x;i++)
							printf("4");
						flag=false;
					}
					sx--;
					printf("7");
				}
				for(i=1;i<=y;i++)
					printf("7");
				printf("4");
				printf("\n");
			}
			else
			{
				y-=(sx+1);
				x-=sx;
				if(x<0||y<0)
				{
					printf("-1\n");
					continue;
				}
				bool flag=true;
				for(i=1;i<=sx;i++)
					printf("74");
				for(i=1;i<=y;i++)
					printf("7");
				printf("\n");
			}
		}
		else if(sx==sy-1)
		{
			x-=sy;
			y-=sy;
			if(x<0||y<0)
			{
				printf("-1\n");
				continue;
			}
			printf("7");
			for(i=1;i<=x;i++)
				printf("4");
			for(i=1;i<=sx;i++)
				printf("47");
			for(i=1;i<=y;i++)
				printf("7");
			printf("4");
			printf("\n");
		}
		else printf("-1\n");
	}
	return 0;
 }


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef vector<pair<int,int> > vpii;

// Order Statistic Tree

/* Special functions:

		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define ALL(a) a.begin(), a.end()
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007LL
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(J,0,v.size()) cout<<v[J]<<" "; cout<<endl
#define endl "\n"
#define PrintPair(x) cout<<x.first<<" "<<x.second<<endl
#define ClearQ(x); while(!x.empty()) x.pop()
#define EPS 1e-9
#define ArrPrint(a,st,en) for(int J=st; J<=en; J++) cout<<a[J]<<" "; cout<<endl;

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll getnum()
{
    char c = getchar();
    ll num,sign=1;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;
    for(num=0;c>='0'&&c<='9';)
    {
        c-='0';
        num = num*10+c;
        c=getchar();
    }
    return num*sign;
}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int a, b, c, d;

void find(string &out)
{
	string x="", y="";

	FOR(i,0,a) x+="4";
	FOR(i,0,b) y+="7";

	// cout<<x<<" "<<y<<endl;

	FOR(i,0,out.size())
	{
		if(out[i]=='4')
		{
			out.insert(i,x);
			break;
		}
	}

	FORr(i,out.size()-1,0)
	{
		if(out[i]=='7')
		{
			out.insert(i,y);
			break;
		}
	}

	prnt(out);
}

int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL); cout.tie(NULL);
    // freopen("in.txt","r",stdin);

    int test, cases=1;

    cin>>a>>b>>c>>d;

    string out="";

    if(abs(c-d)>1)
    {
    	prnt(-1);
    	return 0;
    }

    if(c>d)
    {
    	FOR(i,0,c) out+="47";
    	a-=c;
    	b-=c;

    	if(a<0 || b<0) prnt(-1);
    	else
    	{
    		find(out);
    	}
    }
    else if(d>c)
    {
    	FOR(i,0,d) out+="74";
    	a-=d;
    	b-=d;

    	if(a<0 || b<0) prnt(-1);
    	else
    	{
    		find(out);
    	}
    }
    else if(c==d)
    {
    	FOR(i,0,c) out+="47";

    	out+="4";
    	// prnt(out);

    	if(a-c-1<0 || b-c<0)
    	{
    		// prnt(-1);
    		out="";

    		FOR(i,0,d) out+="74";
    		out+="7";

    		a-=d;
    		b-=d;
    		b--;

    		if(a<0 || b<0) prnt(-1);
    		else
    		{
    			find(out);
    		}
    	}
    	else
    	{
    		// debug;
    		a-=(c+1); b-=c;
    		find(out);
    	}
    }

    // prnt(out);

    return 0;
}


/****** BISMILLAH HIR RAHMANIR RAHIM ******/

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef vector<pair<int,int> > vpii;

// Order Statistic Tree

/* Special functions:

		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define ALL(a) a.begin(), a.end()
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007LL
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(J,0,v.size()) cout<<v[J]<<" "; cout<<endl
#define endl "\n"
#define PrintPair(x) cout<<x.first<<" "<<x.second<<endl
#define ClearQ(x); while(!x.empty()) x.pop()
#define EPS 1e-9
#define ArrPrint(a,st,en) for(int J=st; J<=en; J++) cout<<a[J]<<" "; cout<<endl;

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll getnum()
{
    char c = getchar();
    ll num,sign=1;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;
    for(num=0;c>='0'&&c<='9';)
    {
        c-='0';
        num = num*10+c;
        c=getchar();
    }
    return num*sign;
}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int a, b, c, d;

int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL); cout.tie(NULL);
    // freopen("in.txt","r",stdin);

    int test, cases=1;

    cin>>a>>b>>c>>d;

    string out="";

    if(abs(c-d)>1)
    {
    	prnt(-1);
    	return 0;
    }

    if(c>=d)
    {
    	FOR(i,0,c) out+="47";
    	a-=c;
    	b-=c;
    }
    else
    {
    	FOR(i,0,d) out+="74";
    	a-=d;
    	b-=d;
    }

    if(c==d)
    {
    	out+="4";
    	a--;
    }

    // prnt(out);

    if(a<0 || b<0) prnt(-1);
    else
    {
    	string x="", y="";

    	FOR(i,0,a) x+="4";
    	FOR(i,0,b) y+="7";

    	// cout<<x<<" "<<y<<endl;

    	FOR(i,0,out.size())
    	{
    		if(out[i]=='4')
    		{
    			out.insert(i,x);
    			break;
    		}
    	}

    	FORr(i,out.size()-1,0)
    	{
    		if(out[i]=='7')
    		{
    			out.insert(i,y);
    			break;
    		}
    	}

    	prnt(out);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[4];

int main() {
  for (int i = 1; i <= 4; ++i) {
    scanf("%d", a + i);
  }
  vector<pair<char, int> > ans;
  if (abs(a[3] - a[4]) > 1) {
    puts("-1");
    return 0;
  }
  if (a[3] > a[4]) {
    if (a[1] >= a[3] && a[2] >= a[3]) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('4', 1));
        ans.push_back(make_pair('7', 1));
      }
      ans[0].second += a[1] - a[3];
      ans[ans.size() - 1].second += a[2] - a[3];
    }
    else {
      puts("-1");
      return 0;
    }
  }
  else if (a[3] == a[4]) {
    if (a[3] == 0) {
      if ((long long)a[1] * a[2] != 0) {
        puts("-1");
        return 0;
      }
      else {
        for (int i = 0; i < a[1]; ++i)
          putchar('4');
        for (int i = 0; i < a[2]; ++i)
          putchar('7');
        putchar('\n');
        return 0;
      }
    }
    if (a[1] >= a[3] + 1 && a[2] >= a[3]) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('4', 1));
        ans.push_back(make_pair('7', 1));
      }
      ans.push_back(make_pair('4', 1));
      ans[0].second += a[1] - a[3] - 1;
      ans[ans.size() - 2].second += a[2] - a[3];
    }
    else if (a[2] >= a[3] + 1 && a[1] >= a[3]) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('7', 1));
        ans.push_back(make_pair('4', 1));
      }
      ans.push_back(make_pair('7', 1));
      ans[1].second += a[1] - a[3];
      ans[ans.size() - 1].second += a[2] - a[3] - 1;
    }
    else {
      puts("-1");
      return 0;
    }
  }
  else {
    if (a[1] >= a[4] && a[2] >= a[4]) {
      for (int i = 0; i < a[4]; ++i) {
        ans.push_back(make_pair('7', 1));
        ans.push_back(make_pair('4', 1));
      }
      ans[1].second += a[1] - a[4];
      ans[ans.size() - 2].second += a[2] - a[4];
    }
    else {
      puts("-1");
      return 0;
    }
  }
  for (int i = 0; i < ans.size(); ++i) {
    for (int j = 0; j < ans[i].second; ++j) {
      putchar(ans[i].first);
    }
  }
  putchar('\n');
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[4];

int main() {
  for (int i = 1; i <= 4; ++i) {
    scanf("%d", a + i);
  }
  vector<pair<char, int> > ans;
  if (abs(a[3] - a[4]) > 1) {
    puts("-1");
    return 0;
  }
  if (a[3] > a[4]) {
    if (a[1] >= a[3] && a[2] >= a[3]) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('4', 1));
        ans.push_back(make_pair('7', 1));
      }
      ans[0].second += a[1] - a[3];
      ans[ans.size() - 1].second += a[2] - a[3];
    }
    else {
      puts("-1");
      return 0;
    }
  }
  else if (a[3] == a[4]) {
    if (a[3] == 0) {
      if ((long long)a[1] * a[2] != 0) {
        puts("-1");
        return 0;
      }
      else {
        for (int i = 0; i < a[1]; ++i)
          putchar('4');
        for (int i = 0; i < a[2]; ++i)
          putchar('7');
        putchar('\n');
        return 0;
      }
    }
    if (a[1] >= a[3] + 1) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('4', 1));
        ans.push_back(make_pair('7', 1));
      }
      ans.push_back(make_pair('4', 1));
      ans[0].second += a[1] - a[3] - 1;
      ans[ans.size() - 2].second += a[2] - a[3];
    }
    else if (a[2] >= a[3] + 1) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('7', 1));
        ans.push_back(make_pair('4', 1));
      }
      ans.push_back(make_pair('7', 1));
      ans[1].second += a[1] - a[3];
      ans[ans.size() - 1].second += a[2] - a[3] - 1;
    }
    else {
      puts("-1");
      return 0;
    }
  }
  else {
    if (a[1] >= a[4] && a[2] >= a[4]) {
      for (int i = 0; i < a[4]; ++i) {
        ans.push_back(make_pair('7', 1));
        ans.push_back(make_pair('4', 1));
      }
      ans[1].second += a[1] - a[4];
      ans[ans.size() - 2].second += a[2] - a[4];
    }
    else {
      puts("-1");
      return 0;
    }
  }
  for (int i = 0; i < ans.size(); ++i) {
    for (int j = 0; j < ans[i].second; ++j) {
      putchar(ans[i].first);
    }
  }
  putchar('\n');
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[4];
vector<pair<char, int> > ans;

int main() {
  for (int i = 1; i <= 4; ++i) {
    scanf("%d", a + i);
  }
//  vector<pair<char, int> > ans;
  if (abs(a[3] - a[4]) > 1) {
    puts("-1");
    return 0;
  }
  if (a[3] > a[4]) {
    if (a[1] >= a[3] && a[2] >= a[3]) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('4', 1));
        ans.push_back(make_pair('7', 1));
      }
      ans[0].second += a[1] - a[3];
      ans[ans.size() - 1].second += a[2] - a[3];
    }
    else {
      puts("-1");
      return 0;
    }
  }
  else if (a[3] == a[4]) {
    if (a[3] == 0) {
      if ((long long)a[1] * a[2] != 0) {
        puts("-1");
        return 0;
      }
      else {
        for (int i = 0; i < a[1]; ++i)
          putchar('4');
        for (int i = 0; i < a[2]; ++i)
          putchar('7');
        putchar('\n');
        return 0;
      }
    }
    if (a[1] >= a[3] + 1 && a[2] >= a[3]) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('4', 1));
        ans.push_back(make_pair('7', 1));
      }
      ans.push_back(make_pair('4', 1));
      ans[0].second += a[1] - a[3] - 1;
      ans[ans.size() - 2].second += a[2] - a[3];
    }
    else if (a[2] >= a[3] + 1 && a[1] >= a[3]) {
      for (int i = 0; i < a[3]; ++i) {
        ans.push_back(make_pair('7', 1));
        ans.push_back(make_pair('4', 1));
      }
      ans.push_back(make_pair('7', 1));
      ans[1].second += a[1] - a[3];
      ans[ans.size() - 1].second += a[2] - a[3] - 1;
    }
    else {
      puts("-1");
      return 0;
    }
  }
  else {
    if (a[1] >= a[4] && a[2] >= a[4]) {
      for (int i = 0; i < a[4]; ++i) {
        ans.push_back(make_pair('7', 1));
        ans.push_back(make_pair('4', 1));
      }
      ans[1].second += a[1] - a[4];
      ans[ans.size() - 2].second += a[2] - a[4];
    }
    else {
      puts("-1");
      return 0;
    }
  }
  for (int i = 0; i < ans.size(); ++i) {
    for (int j = 0; j < ans[i].second; ++j) {
      putchar(ans[i].first);
    }
  }
  putchar('\n');
  return 0;
}


#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#ifdef LOCAL
#define debug(x) {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, t) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#t <<" = " <<t<<"\n";}
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define debug4(x,y,z,t)
#define debugv(x)
#define cerr if(0)cout
#endif
#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
using namespace std;
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third; };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}

void Exit() {
  cout<<"-1\n";
  exit(0);
}
VI res;
VI trures;
int inv;
int t4, t7, t47, t74;
void Print() {
  for (auto x : res) {
    if ((x == 4 && !inv) || (x == 7 && inv)) {
      trures.PB(4);
      cout<<4;
    } else {
      trures.PB(7);
      cout<<7;
    }
  }
  for (int i = 0; i < SZ(trures); i++) {
    if (trures[i] == 4) { t4--; }
    if (trures[i] == 7) { t7--; }
    if (i < SZ(trures) - 1 && trures[i] == 4 && trures[i + 1] == 7) { t47--; }
    if (i < SZ(trures) - 1 && trures[i] == 7 && trures[i + 1] == 4) { t74--; }
  }
  //debug(t4, t7, t47
  cout<<endl;
  assert(t4 == 0 && t7 == 0 && t47 == 0 && t74 == 0);

}
#undef int
int main() {
#define int long long

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;

  make4(int, c4, c7, c47, c74);
  if (abs(c47 - c74) > 1) {
    Exit();
  }
  t4 = c4;
  t7 = c7;
  t47 = c47;
  t74 = c74;
  if (min(c4, c7) < max(c47, c74) || c4 + c7 == c47 + c74) {
    Exit();
  }

//   if (c47 < c74) {
//     swap(c4, c7);
//     swap(c47, c74);
//     inv ^= 1;
//   }
  if (c47 > c74) {

      cerr<<"Cas1\n";
    res.PB(4);
    RE (i, c4 - c47) {
      res.PB(4);
    }
    res.PB(7);
    RE (i, c47 - 1) {
      res.PB(4);
      res.PB(7);
    }
    RE (i, c7 - c47) {
      res.PB(7);
    }
  } else if (c74 > c47) {

    cerr<<"Cas2\n";
    res.PB(7);
    RE (i, c4 - c74 + 1) {
      res.PB(4);
    }
    RE (i, c74 - 1) {
      res.PB(7);
      res.PB(4);
    }
    res.pop_back();
    RE (i, c7 - c74) {
      res.PB(7);
    }
    res.PB(4);
  } else {
    if (c4 > c47) {

      cerr<<"Cas3\n";
      res.PB(4);
      RE (i, c4 - c47 - 1) {
        res.PB(4);
      }
      RE (i, c74) {
        res.PB(7);
        res.PB(4);
      }
      res.pop_back();
      RE (i, c7 - c74) {
        res.PB(7);
      }
      res.PB(4);
    } else {
      cerr<<"Cas4\n";
      res.PB(7);
      RE (i, c47) {
        res.PB(4);
        res.PB(7);
      }
      RE (i, c7 - c74 - 1) {
        res.PB(7);
      }

    }
  }
  Print();

  assert(SZ(res) == c4 + c7);

  return 0;
}


#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#ifdef LOCAL
#define debug(x) {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, t) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#t <<" = " <<t<<"\n";}
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define debug4(x,y,z,t)
#define debugv(x)
#define cerr if(0)cout
#endif
#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
using namespace std;
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third; };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}

void Exit() {
  cout<<"-1\n";
  exit(0);
}
VI res;
int inv;
void Print() {
  for (auto x : res) {
    if ((x == 4 && !inv) || (x == 7 && inv)) {
      cout<<4;
    } else {
      cout<<7;
    }
  }
  cout<<"\n";
}
#undef int
int main() {
#define int long long

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;

  make4(int, c4, c7, c47, c74);
  if (abs(c47 - c74) > 1) {
    Exit();
  }
  if (min(c4, c7) < max(c47, c74) || c4 + c7 == c47 + c74) {
    Exit();
  }

  if (c47 < c74) {
    swap(c4, c7);
    swap(c47, c74);
    inv ^= 1;
  }
  if (c47 > c74) {
    res.PB(4);
    RE (i, c4 - c47) {
      res.PB(4);
    }
    res.PB(7);
    RE (i, c7 - c47) {
      res.PB(7);
    }
    RE (i, c47 - 1) {
      res.PB(4);
      res.PB(7);
    }
  } else {
    if (c4 < c7) {
      swap(c4, c7);
      swap(c47, c74);
      inv ^= 1;
    }
    res.PB(4);
    assert(c4 >= c47 + 1);
    RE (i, c4 - c47 - 1) {
      res.PB(4);
    }
    RE (i, c7 - c47) {
      res.PB(7);
    }
    RE (i, c47) {
      res.PB(7);
      res.PB(4);
    }
  }
  Print();

  return 0;
}


#include <bits/stdc++.h>
#define M_PI    3.14159265358979323846ll
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n)-1;i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define FR(i,s,n) for(int i=(n);i>=(s);i--)
#define all(a) a.begin(),a.end()
#define tnm typename
#define invd inline int
#define templ1 template<tnm T>
#define btempl templ1 invd
#define ln prln()
#define sp prsp()
using namespace std;
void init(string name){
  string path = "../../../Downloads/"+name+".in";
  string out = name+".out";
  freopen(path.c_str(),"r",stdin);
  freopen(out.c_str(),"w",stdout);
}

invd init(int n){
  char buff[100];
  sprintf(buff,"xx/%d.txt",n);
#ifndef ONLINE_JUDGE
    freopen(buff,"r",stdin);
#endif
}
typedef int64_t ll;typedef unsigned int uint;
invd scan(char&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');s=c;};
invd pr(ll i){printf("%" PRId64 ,i);}
invd scan(int&i){return scanf("%d",&i);}invd scan(double&i){return scanf("%lf",&i);}invd scan(ll&i){return scanf("%" PRId64 ,&i);}invd pr(const string&s){ff(i,0,s.size())putchar(s[i]);}
invd scan(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case' ':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd scanln(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd pr(char c){putchar(c);};invd pr(const char*c){while(*c!=0)putchar(*c++);}
invd pr(int i){printf("%d",i);}invd pr(bool b){pr((int)b);}invd pr(double d){printf("%.9lf",d);}invd prln(){putchar('\n');}invd prsp(){putchar(' ');}
btempl scan(char*s){int c;while((c=getchar())){switch(c){case'\n':case'\r':case' ':break;default:*s++=c;}}*s=0;};
template<typename T>invd scan(T&arg) {return arg.scan();}
template<typename T, typename V> invd scan(pair<T,V>&a){scan(a.first),scan(a.second);}
btempl scan(vector<T>&v){for(T&t:v)scan(t);}btempl scan(T*a,int n){while(n--)scan(*a++);}
template<typename T, typename... Args>invd scan(T&first, Args (&... args)) {scan(first),scan(args...);}
template<typename T>invd pr(T arg) {arg.print();}
template<class A, class B> invd pr(pair<A,B> a){pr(a.first),sp,pr(a.second);}
btempl prsp(vector<T>&v){if(v.size())pr(v[0]);ff(i,1,v.size())sp,pr(v[i]);}btempl prsp(T*a,int n){while(n--)pr(*a++),sp;}btempl prln(vector<T>&v){for(const T&t:v)pr(t),ln;}
btempl pr(vector<T>&v){prsp(v);}
invd pr(size_t i){pr((ll)i);}
btempl prln(T*a,int n){while(n--)pr(*a++),ln;}btempl prln(vector<vector<T> >&v){for(vector<T>&t:v)prsp(t),ln;}
template<typename T, typename U>invd prln(T first, U second) {pr(first),ln,pr(second);}
template<typename T, typename... Args>invd prln(T first, Args... args) {pr(first),ln,prln(args...);}
template<typename T, typename... Args>invd pr(T first, Args... args) {pr(first),sp,pr(args...);}
templ1 vector<T>& operator+=(vector<T>& v,T x) {v.push_back(x);return v;}
templ1 vector<T>& operator--(vector<T>& v) {v.pop_back();return v;}templ1 vector<T>& operator--(vector<T>& v,int) {v.pop_back();return v;}
templ1 bool operator!(stack<T>&q) {return !q.empty();}templ1 stack<T>& operator+=(stack<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(stack<T>& v) {v.pop();return v.top();}templ1 T operator--(stack<T>& v,int) {T t=v.top();v.pop();return t;}
templ1 bool operator!(queue<T>&q) {return !q.empty();}templ1 queue<T>& operator+=(queue<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(queue<T>& v) {v.pop();return v.front();}templ1 T operator--(queue<T>& v,int) {T t=v.front();v.pop();return t;}
template<tnm T,tnm U>invd smax(T&a,U b){if(b>a)a=b;}template<tnm T,tnm U>invd smin(T&a,U b){if(b<a)a=b;}
template<tnm T,tnm U>inline T gcd(T a, U b){return __gcd(a,b);}typedef vector<int> vi;typedef vector<vi > vvi;typedef pair<int, int> pii;typedef pair<ll,ll> pll;
int getint(){
  int x;scan(x);return x;
}
#define gi getint()

typedef vector<pii > vpii;
typedef vector<ll > vll;
ll MOD = 1E9+7;
const ll linf=~(1ll<<63);
const int inf=~(1<<31);
const int sk = 1E9;

struct mem{
  int loc, size, id;
  void print(){
    pr(loc,size);
  }
};

struct problem{
  int a, b, c, d;

  int last = 0;

  int solve(){
    int n = a+b;
    if(abs(c-d)>1)return pr(-1);
    if(min(a,b)<max(c,d))return pr(-1);
    if(d+1==c){
      string s(n,'4');
      s.back()='7';
      b--;
      fr(i,1,n-1){
        if((n-i)&1||d<=0){
          s[i]='7';
          d--;
          b--;
          if(b==0)break;
        }
      }
      pr(s);

    }else if(c+1==d){
      string s(n,'7');
      s.back()='4';
      a--,d--;
      ff(i,1,n){
        if(i&1||d<=0){
          s[i]='4';
          d--;
          a--;
          if(a==0)break;
        }
      }
      pr(s);

    }else if(c==d){
      if(a>c){
        string s(n,'4');
        fr(i,1,n-1){
          if((n-i-1)&1||d<=0){
            s[i]='7';
            d--;
            b--;
            if(b==0)break;
          }
        }
        pr(s);
      }else if(b>c){
        string s(n,'7');
        a--;
        ff(i,1,n){
          if(i&1||d<=0){
            s[i]='4';
            d--;
            a--;
            if(a==0)break;
          }
        }
        pr(s);

      }else return pr(-1);

    }
  }

  problem(){
    scan(a,b,c,d);
  }

};

int main(){
  init(5);
  problem px = {};
  px.solve();
}


#include <bits/stdc++.h>
#define M_PI    3.14159265358979323846ll
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n)-1;i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define FR(i,s,n) for(int i=(n);i>=(s);i--)
#define all(a) a.begin(),a.end()
#define tnm typename
#define invd inline int
#define templ1 template<tnm T>
#define btempl templ1 invd
#define ln prln()
#define sp prsp()
using namespace std;
void init(string name){
  string path = "../../../Downloads/"+name+".in";
  string out = name+".out";
  freopen(path.c_str(),"r",stdin);
  freopen(out.c_str(),"w",stdout);
}

invd init(int n){
  char buff[100];
  sprintf(buff,"xx/%d.txt",n);
#ifndef ONLINE_JUDGE
    freopen(buff,"r",stdin);
#endif
}
typedef int64_t ll;typedef unsigned int uint;
invd scan(char&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');s=c;};
invd pr(ll i){printf("%" PRId64 ,i);}
invd scan(int&i){return scanf("%d",&i);}invd scan(double&i){return scanf("%lf",&i);}invd scan(ll&i){return scanf("%" PRId64 ,&i);}invd pr(const string&s){ff(i,0,s.size())putchar(s[i]);}
invd scan(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case' ':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd scanln(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd pr(char c){putchar(c);};invd pr(const char*c){while(*c!=0)putchar(*c++);}
invd pr(int i){printf("%d",i);}invd pr(bool b){pr((int)b);}invd pr(double d){printf("%.9lf",d);}invd prln(){putchar('\n');}invd prsp(){putchar(' ');}
btempl scan(char*s){int c;while((c=getchar())){switch(c){case'\n':case'\r':case' ':break;default:*s++=c;}}*s=0;};
template<typename T>invd scan(T&arg) {return arg.scan();}
template<typename T, typename V> invd scan(pair<T,V>&a){scan(a.first),scan(a.second);}
btempl scan(vector<T>&v){for(T&t:v)scan(t);}btempl scan(T*a,int n){while(n--)scan(*a++);}
template<typename T, typename... Args>invd scan(T&first, Args (&... args)) {scan(first),scan(args...);}
template<typename T>invd pr(T arg) {arg.print();}
template<class A, class B> invd pr(pair<A,B> a){pr(a.first),sp,pr(a.second);}
btempl prsp(vector<T>&v){if(v.size())pr(v[0]);ff(i,1,v.size())sp,pr(v[i]);}btempl prsp(T*a,int n){while(n--)pr(*a++),sp;}btempl prln(vector<T>&v){for(const T&t:v)pr(t),ln;}
btempl pr(vector<T>&v){prsp(v);}
invd pr(size_t i){pr((ll)i);}
btempl prln(T*a,int n){while(n--)pr(*a++),ln;}btempl prln(vector<vector<T> >&v){for(vector<T>&t:v)prsp(t),ln;}
template<typename T, typename U>invd prln(T first, U second) {pr(first),ln,pr(second);}
template<typename T, typename... Args>invd prln(T first, Args... args) {pr(first),ln,prln(args...);}
template<typename T, typename... Args>invd pr(T first, Args... args) {pr(first),sp,pr(args...);}
templ1 vector<T>& operator+=(vector<T>& v,T x) {v.push_back(x);return v;}
templ1 vector<T>& operator--(vector<T>& v) {v.pop_back();return v;}templ1 vector<T>& operator--(vector<T>& v,int) {v.pop_back();return v;}
templ1 bool operator!(stack<T>&q) {return !q.empty();}templ1 stack<T>& operator+=(stack<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(stack<T>& v) {v.pop();return v.top();}templ1 T operator--(stack<T>& v,int) {T t=v.top();v.pop();return t;}
templ1 bool operator!(queue<T>&q) {return !q.empty();}templ1 queue<T>& operator+=(queue<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(queue<T>& v) {v.pop();return v.front();}templ1 T operator--(queue<T>& v,int) {T t=v.front();v.pop();return t;}
template<tnm T,tnm U>invd smax(T&a,U b){if(b>a)a=b;}template<tnm T,tnm U>invd smin(T&a,U b){if(b<a)a=b;}
template<tnm T,tnm U>inline T gcd(T a, U b){return __gcd(a,b);}typedef vector<int> vi;typedef vector<vi > vvi;typedef pair<int, int> pii;typedef pair<ll,ll> pll;
int getint(){
  int x;scan(x);return x;
}
#define gi getint()

typedef vector<pii > vpii;
typedef vector<ll > vll;
ll MOD = 1E9+7;
const ll linf=~(1ll<<63);
const int inf=~(1<<31);
const int sk = 1E9;

struct mem{
  int loc, size, id;
  void print(){
    pr(loc,size);
  }
};

struct problem{
  int a, b, c, d;

  int last = 0;

  int solve(){
    int n = a+b;
    if(abs(c-d)>1)return pr(-1);
    if(min(a,b)<max(c,d))return pr(-1);
    if(d+1==c){
      string s(n,'4');
      s.back()='7';
      b--;
      ff(i,1,n){
        if(i&1||d<=0){
          s[i]='7';
          d--;
          b--;
          if(b==0)break;
        }
      }
      pr(s);

    }else if(c+1==d){
      string s(n,'7');
      s.back()='4';
      a--,d--;
      ff(i,1,n){
        if(i&1||d<=0){
          s[i]='4';
          d--;
          a--;
          if(a==0)break;
        }
      }
      pr(s);

    }else if(c==d){
      if(a>c){
        string s(n,'4');
        ff(i,1,n){
          if(i&1||d<=0){
            s[i]='7';
            d--;
            b--;
            if(b==0)break;
          }
        }
        pr(s);
      }else if(b>c){
        string s(n,'7');
        a--;
        ff(i,1,n){
          if(i&1||d<=0){
            s[i]='4';
            d--;
            a--;
            if(a==0)break;
          }
        }
        pr(s);

      }else return pr(-1);

    }
  }

  problem(){
    scan(a,b,c,d);
  }

};

int main(){
  init(3);
  problem px = {};
  px.solve();
}


#include <bits/stdc++.h>
#define M_PI    3.14159265358979323846ll
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n)-1;i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define FR(i,s,n) for(int i=(n);i>=(s);i--)
#define all(a) a.begin(),a.end()
#define tnm typename
#define invd inline int
#define templ1 template<tnm T>
#define btempl templ1 invd
#define ln prln()
#define sp prsp()
using namespace std;
void init(string name){
  string path = "../../../Downloads/"+name+".in";
  string out = name+".out";
  freopen(path.c_str(),"r",stdin);
  freopen(out.c_str(),"w",stdout);
}

invd init(int n){
  char buff[100];
  sprintf(buff,"xx/%d.txt",n);
#ifndef ONLINE_JUDGE
    freopen(buff,"r",stdin);
#endif
}
typedef int64_t ll;typedef unsigned int uint;
invd scan(char&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');s=c;};
invd pr(ll i){printf("%" PRId64 ,i);}
invd scan(int&i){return scanf("%d",&i);}invd scan(double&i){return scanf("%lf",&i);}invd scan(ll&i){return scanf("%" PRId64 ,&i);}invd pr(const string&s){ff(i,0,s.size())putchar(s[i]);}
invd scan(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case' ':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd scanln(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd pr(char c){putchar(c);};invd pr(const char*c){while(*c!=0)putchar(*c++);}
invd pr(int i){printf("%d",i);}invd pr(bool b){pr((int)b);}invd pr(double d){printf("%.9lf",d);}invd prln(){putchar('\n');}invd prsp(){putchar(' ');}
btempl scan(char*s){int c;while((c=getchar())){switch(c){case'\n':case'\r':case' ':break;default:*s++=c;}}*s=0;};
template<typename T>invd scan(T&arg) {return arg.scan();}
template<typename T, typename V> invd scan(pair<T,V>&a){scan(a.first),scan(a.second);}
btempl scan(vector<T>&v){for(T&t:v)scan(t);}btempl scan(T*a,int n){while(n--)scan(*a++);}
template<typename T, typename... Args>invd scan(T&first, Args (&... args)) {scan(first),scan(args...);}
template<typename T>invd pr(T arg) {arg.print();}
template<class A, class B> invd pr(pair<A,B> a){pr(a.first),sp,pr(a.second);}
btempl prsp(vector<T>&v){if(v.size())pr(v[0]);ff(i,1,v.size())sp,pr(v[i]);}btempl prsp(T*a,int n){while(n--)pr(*a++),sp;}btempl prln(vector<T>&v){for(const T&t:v)pr(t),ln;}
btempl pr(vector<T>&v){prsp(v);}
invd pr(size_t i){pr((ll)i);}
btempl prln(T*a,int n){while(n--)pr(*a++),ln;}btempl prln(vector<vector<T> >&v){for(vector<T>&t:v)prsp(t),ln;}
template<typename T, typename U>invd prln(T first, U second) {pr(first),ln,pr(second);}
template<typename T, typename... Args>invd prln(T first, Args... args) {pr(first),ln,prln(args...);}
template<typename T, typename... Args>invd pr(T first, Args... args) {pr(first),sp,pr(args...);}
templ1 vector<T>& operator+=(vector<T>& v,T x) {v.push_back(x);return v;}
templ1 vector<T>& operator--(vector<T>& v) {v.pop_back();return v;}templ1 vector<T>& operator--(vector<T>& v,int) {v.pop_back();return v;}
templ1 bool operator!(stack<T>&q) {return !q.empty();}templ1 stack<T>& operator+=(stack<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(stack<T>& v) {v.pop();return v.top();}templ1 T operator--(stack<T>& v,int) {T t=v.top();v.pop();return t;}
templ1 bool operator!(queue<T>&q) {return !q.empty();}templ1 queue<T>& operator+=(queue<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(queue<T>& v) {v.pop();return v.front();}templ1 T operator--(queue<T>& v,int) {T t=v.front();v.pop();return t;}
template<tnm T,tnm U>invd smax(T&a,U b){if(b>a)a=b;}template<tnm T,tnm U>invd smin(T&a,U b){if(b<a)a=b;}
template<tnm T,tnm U>inline T gcd(T a, U b){return __gcd(a,b);}typedef vector<int> vi;typedef vector<vi > vvi;typedef pair<int, int> pii;typedef pair<ll,ll> pll;
int getint(){
  int x;scan(x);return x;
}
#define gi getint()

typedef vector<pii > vpii;
typedef vector<ll > vll;
ll MOD = 1E9+7;
const ll linf=~(1ll<<63);
const int inf=~(1<<31);
const int sk = 1E9;

struct mem{
  int loc, size, id;
  void print(){
    pr(loc,size);
  }
};

struct problem{
  int a, b, c, d;

  int last = 0;

  int solve(){
    int n = a+b;
    if(abs(c-d)>1)return pr(-1);
    if(min(a,b)<max(c,d))return pr(-1);
    if(c+1==d){
      string s(n,'4');
      s.back()='7';
      b--;
      ff(i,1,n){
        if(i&1||d<=0){
          s[i]='7';
          d--;
          b--;
          if(b==0)break;
        }
      }
      pr(s);

    }else if(d+1==c){
      string s(n,'7');
      s.back()='4';
      a--,d--;
      ff(i,1,n){
        if(i&1||d<=0){
          s[i]='4';
          d--;
          a--;
          if(a==0)break;
        }
      }
      pr(s);

    }else if(c==d){
      if(a>c){
        string s(n,'4');
        ff(i,1,n){
          if(i&1||d<=0){
            s[i]='7';
            d--;
            b--;
            if(b==0)break;
          }
        }
        pr(s);
      }else if(b>c){
        string s(n,'7');
        a--;
        ff(i,1,n){
          if(i&1||d<=0){
            s[i]='4';
            d--;
            a--;
            if(a==0)break;
          }
        }
        pr(s);

      }else return pr(-1);

    }
  }

  problem(){
    scan(a,b,c,d);
  }

};

int main(){
  init(2);
  problem px = {};
  px.solve();
}


#include <bits/stdc++.h>
#define M_PI    3.14159265358979323846ll
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n)-1;i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define FR(i,s,n) for(int i=(n);i>=(s);i--)
#define all(a) a.begin(),a.end()
#define tnm typename
#define invd inline int
#define templ1 template<tnm T>
#define btempl templ1 invd
#define ln prln()
#define sp prsp()
using namespace std;
void init(string name){
  string path = "../../../Downloads/"+name+".in";
  string out = name+".out";
  freopen(path.c_str(),"r",stdin);
  freopen(out.c_str(),"w",stdout);
}

invd init(int n){
  char buff[100];
  sprintf(buff,"xx/%d.txt",n);
#ifndef ONLINE_JUDGE
    freopen(buff,"r",stdin);
#endif
}
typedef int64_t ll;typedef unsigned int uint;
invd scan(char&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');s=c;};
invd pr(ll i){printf("%" PRId64 ,i);}
invd scan(int&i){return scanf("%d",&i);}invd scan(double&i){return scanf("%lf",&i);}invd scan(ll&i){return scanf("%" PRId64 ,&i);}invd pr(const string&s){ff(i,0,s.size())putchar(s[i]);}
invd scan(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case' ':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd scanln(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd pr(char c){putchar(c);};invd pr(const char*c){while(*c!=0)putchar(*c++);}
invd pr(int i){printf("%d",i);}invd pr(bool b){pr((int)b);}invd pr(double d){printf("%.9lf",d);}invd prln(){putchar('\n');}invd prsp(){putchar(' ');}
btempl scan(char*s){int c;while((c=getchar())){switch(c){case'\n':case'\r':case' ':break;default:*s++=c;}}*s=0;};
template<typename T>invd scan(T&arg) {return arg.scan();}
template<typename T, typename V> invd scan(pair<T,V>&a){scan(a.first),scan(a.second);}
btempl scan(vector<T>&v){for(T&t:v)scan(t);}btempl scan(T*a,int n){while(n--)scan(*a++);}
template<typename T, typename... Args>invd scan(T&first, Args (&... args)) {scan(first),scan(args...);}
template<typename T>invd pr(T arg) {arg.print();}
template<class A, class B> invd pr(pair<A,B> a){pr(a.first),sp,pr(a.second);}
btempl prsp(vector<T>&v){if(v.size())pr(v[0]);ff(i,1,v.size())sp,pr(v[i]);}btempl prsp(T*a,int n){while(n--)pr(*a++),sp;}btempl prln(vector<T>&v){for(const T&t:v)pr(t),ln;}
btempl pr(vector<T>&v){prsp(v);}
invd pr(size_t i){pr((ll)i);}
btempl prln(T*a,int n){while(n--)pr(*a++),ln;}btempl prln(vector<vector<T> >&v){for(vector<T>&t:v)prsp(t),ln;}
template<typename T, typename U>invd prln(T first, U second) {pr(first),ln,pr(second);}
template<typename T, typename... Args>invd prln(T first, Args... args) {pr(first),ln,prln(args...);}
template<typename T, typename... Args>invd pr(T first, Args... args) {pr(first),sp,pr(args...);}
templ1 vector<T>& operator+=(vector<T>& v,T x) {v.push_back(x);return v;}
templ1 vector<T>& operator--(vector<T>& v) {v.pop_back();return v;}templ1 vector<T>& operator--(vector<T>& v,int) {v.pop_back();return v;}
templ1 bool operator!(stack<T>&q) {return !q.empty();}templ1 stack<T>& operator+=(stack<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(stack<T>& v) {v.pop();return v.top();}templ1 T operator--(stack<T>& v,int) {T t=v.top();v.pop();return t;}
templ1 bool operator!(queue<T>&q) {return !q.empty();}templ1 queue<T>& operator+=(queue<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(queue<T>& v) {v.pop();return v.front();}templ1 T operator--(queue<T>& v,int) {T t=v.front();v.pop();return t;}
template<tnm T,tnm U>invd smax(T&a,U b){if(b>a)a=b;}template<tnm T,tnm U>invd smin(T&a,U b){if(b<a)a=b;}
template<tnm T,tnm U>inline T gcd(T a, U b){return __gcd(a,b);}typedef vector<int> vi;typedef vector<vi > vvi;typedef pair<int, int> pii;typedef pair<ll,ll> pll;
int getint(){
  int x;scan(x);return x;
}
#define gi getint()

typedef vector<pii > vpii;
typedef vector<ll > vll;
ll MOD = 1E9+7;
const ll linf=~(1ll<<63);
const int inf=~(1<<31);
const int sk = 1E9;

struct dig{
  char c;
  int s, g;
  int print(){
    return pr(c,s,g);
  }
};

struct problem{
  dig a, b;

  string build(dig a, dig b){
    string res;
    while(a.s){
      if(a.c=='4'){
        res+=a.c,a.s--;
        while(a.s>b.g)res+=a.c,a.s--;
      }else{
        res+=a.c,a.s--;
        if(b.g==0)while(a.s>0)res+=a.c,a.s--;
      }
      if(b.s)
        a.g--;
      swap(a,b);
    }
    if(a.s==0&&a.g==0&&b.s==0&&b.g==0)return res;
    return "";
  }

  int solve(){
    string ans = build(a,b);
    if(ans.size()==a.s+b.s)return pr(ans);
    ans = build(b,a);
    if(ans.size()==a.s+b.s)return pr(ans);
    return pr(-1);

  }

  problem(){
    int x, y, z, w;scan(x,y,z,w);
    a = {'4',x,z};
    b = {'7',y,w};

  }

};

int main(){
  init(4);
  problem px = {};
  px.solve();
}


#include <bits/stdc++.h>
#define M_PI    3.14159265358979323846ll
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n)-1;i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define FR(i,s,n) for(int i=(n);i>=(s);i--)
#define all(a) a.begin(),a.end()
#define tnm typename
#define invd inline int
#define templ1 template<tnm T>
#define btempl templ1 invd
#define ln prln()
#define sp prsp()
using namespace std;
void init(string name){
  string path = "../../../Downloads/"+name+".in";
  string out = name+".out";
  freopen(path.c_str(),"r",stdin);
  freopen(out.c_str(),"w",stdout);
}

invd init(int n){
  char buff[100];
  sprintf(buff,"xx/%d.txt",n);
#ifndef ONLINE_JUDGE
    freopen(buff,"r",stdin);
#endif
}
typedef int64_t ll;typedef unsigned int uint;
invd scan(char&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');s=c;};
invd pr(ll i){printf("%" PRId64 ,i);}
invd scan(int&i){return scanf("%d",&i);}invd scan(double&i){return scanf("%lf",&i);}invd scan(ll&i){return scanf("%" PRId64 ,&i);}invd pr(const string&s){ff(i,0,s.size())putchar(s[i]);}
invd scan(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case' ':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd scanln(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd pr(char c){putchar(c);};invd pr(const char*c){while(*c!=0)putchar(*c++);}
invd pr(int i){printf("%d",i);}invd pr(bool b){pr((int)b);}invd pr(double d){printf("%.9lf",d);}invd prln(){putchar('\n');}invd prsp(){putchar(' ');}
btempl scan(char*s){int c;while((c=getchar())){switch(c){case'\n':case'\r':case' ':break;default:*s++=c;}}*s=0;};
template<typename T>invd scan(T&arg) {return arg.scan();}
template<typename T, typename V> invd scan(pair<T,V>&a){scan(a.first),scan(a.second);}
btempl scan(vector<T>&v){for(T&t:v)scan(t);}btempl scan(T*a,int n){while(n--)scan(*a++);}
template<typename T, typename... Args>invd scan(T&first, Args (&... args)) {scan(first),scan(args...);}
template<typename T>invd pr(T arg) {arg.print();}
template<class A, class B> invd pr(pair<A,B> a){pr(a.first),sp,pr(a.second);}
btempl prsp(vector<T>&v){if(v.size())pr(v[0]);ff(i,1,v.size())sp,pr(v[i]);}btempl prsp(T*a,int n){while(n--)pr(*a++),sp;}btempl prln(vector<T>&v){for(const T&t:v)pr(t),ln;}
btempl pr(vector<T>&v){prsp(v);}
invd pr(size_t i){pr((ll)i);}
btempl prln(T*a,int n){while(n--)pr(*a++),ln;}btempl prln(vector<vector<T> >&v){for(vector<T>&t:v)prsp(t),ln;}
template<typename T, typename U>invd prln(T first, U second) {pr(first),ln,pr(second);}
template<typename T, typename... Args>invd prln(T first, Args... args) {pr(first),ln,prln(args...);}
template<typename T, typename... Args>invd pr(T first, Args... args) {pr(first),sp,pr(args...);}
templ1 vector<T>& operator+=(vector<T>& v,T x) {v.push_back(x);return v;}
templ1 vector<T>& operator--(vector<T>& v) {v.pop_back();return v;}templ1 vector<T>& operator--(vector<T>& v,int) {v.pop_back();return v;}
templ1 bool operator!(stack<T>&q) {return !q.empty();}templ1 stack<T>& operator+=(stack<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(stack<T>& v) {v.pop();return v.top();}templ1 T operator--(stack<T>& v,int) {T t=v.top();v.pop();return t;}
templ1 bool operator!(queue<T>&q) {return !q.empty();}templ1 queue<T>& operator+=(queue<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(queue<T>& v) {v.pop();return v.front();}templ1 T operator--(queue<T>& v,int) {T t=v.front();v.pop();return t;}
template<tnm T,tnm U>invd smax(T&a,U b){if(b>a)a=b;}template<tnm T,tnm U>invd smin(T&a,U b){if(b<a)a=b;}
template<tnm T,tnm U>inline T gcd(T a, U b){return __gcd(a,b);}typedef vector<int> vi;typedef vector<vi > vvi;typedef pair<int, int> pii;typedef pair<ll,ll> pll;
int getint(){
  int x;scan(x);return x;
}
#define gi getint()

typedef vector<pii > vpii;
typedef vector<ll > vll;
ll MOD = 1E9+7;
const ll linf=~(1ll<<63);
const int inf=~(1<<31);
const int sk = 1E9;

struct mem{
  int loc, size, id;
  void print(){
    pr(loc,size);
  }
};

struct problem{
  int a, b, c, d;

  int last = 0;

  int solve(){
    int n = a+b;
    if(abs(c-d)>1)return pr(-1);
    if(min(a,b)<max(c,d))return pr(-1);
    if(d+1==c){
      string s(n,'4');
      s.back()='7';
      b--;
        bool e = 1;
      fr(i,1,n-1){
        if(b>d){
          s[i]='7';
          b--;
        }
        else if(e=!e){
          s[i]='7';
          d--;
          b--;
          if(b==0)break;
        }
      }
      pr(s);

    }else if(c+1==d){
      string s(n,'7');
      s.back()='4';
      a--,d--;
      ff(i,1,n){
        if(i&1||d<=0){
          s[i]='4';
          d--;
          a--;
          if(a==0)break;
        }
      }
      pr(s);

    }else if(c==d){
      if(a>c){
        string s(n,'4');
        d--;
        bool e = 1;
        fr(i,1,n-1){
            if(b>d){
              pr(b),ln;
              s[i]='7';
              b--;
            }
            else if(e=!e){
            s[i]='7';
            d--;
            b--;
            if(b==0)break;
          }
        }
        pr(s);
      }else if(b>c){
        string s(n,'7');
        a--;
        d--;
        ff(i,1,n){
          if(i&1||d<=0){
            s[i]='4';
            d--;
            a--;
            if(a==0)break;
          }
        }
        pr(s);

      }else return pr(-1);

    }
  }

  problem(){
    scan(a,b,c,d);
  }

};

int main(){
  init(1);
  problem px = {};
  px.solve();
}


#include <bits/stdc++.h>
#define M_PI    3.14159265358979323846ll
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n)-1;i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define FR(i,s,n) for(int i=(n);i>=(s);i--)
#define all(a) a.begin(),a.end()
#define tnm typename
#define invd inline int
#define templ1 template<tnm T>
#define btempl templ1 invd
#define ln prln()
#define sp prsp()
using namespace std;
void init(string name){
  string path = "../../../Downloads/"+name+".in";
  string out = name+".out";
  freopen(path.c_str(),"r",stdin);
  freopen(out.c_str(),"w",stdout);
}

invd init(int n){
  char buff[100];
  sprintf(buff,"xx/%d.txt",n);
#ifndef ONLINE_JUDGE
    freopen(buff,"r",stdin);
#endif
}
typedef int64_t ll;typedef unsigned int uint;
invd scan(char&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');s=c;};
invd pr(ll i){printf("%" PRId64 ,i);}
invd scan(int&i){return scanf("%d",&i);}invd scan(double&i){return scanf("%lf",&i);}invd scan(ll&i){return scanf("%" PRId64 ,&i);}invd pr(const string&s){ff(i,0,s.size())putchar(s[i]);}
invd scan(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case' ':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd scanln(string&s){int c;while((c=getchar())=='\n'||c==' '||c=='\r');do{switch(c){case'\n':case'\r':case EOF:return 0;default:s+=c;}}while((c=getchar())!=EOF);return s.size();};
invd pr(char c){putchar(c);};invd pr(const char*c){while(*c!=0)putchar(*c++);}
invd pr(int i){printf("%d",i);}invd pr(bool b){pr((int)b);}invd pr(double d){printf("%.9lf",d);}invd prln(){putchar('\n');}invd prsp(){putchar(' ');}
btempl scan(char*s){int c;while((c=getchar())){switch(c){case'\n':case'\r':case' ':break;default:*s++=c;}}*s=0;};
template<typename T>invd scan(T&arg) {return arg.scan();}
template<typename T, typename V> invd scan(pair<T,V>&a){scan(a.first),scan(a.second);}
btempl scan(vector<T>&v){for(T&t:v)scan(t);}btempl scan(T*a,int n){while(n--)scan(*a++);}
template<typename T, typename... Args>invd scan(T&first, Args (&... args)) {scan(first),scan(args...);}
template<typename T>invd pr(T arg) {arg.print();}
template<class A, class B> invd pr(pair<A,B> a){pr(a.first),sp,pr(a.second);}
btempl prsp(vector<T>&v){if(v.size())pr(v[0]);ff(i,1,v.size())sp,pr(v[i]);}btempl prsp(T*a,int n){while(n--)pr(*a++),sp;}btempl prln(vector<T>&v){for(const T&t:v)pr(t),ln;}
btempl pr(vector<T>&v){prsp(v);}
invd pr(size_t i){pr((ll)i);}
btempl prln(T*a,int n){while(n--)pr(*a++),ln;}btempl prln(vector<vector<T> >&v){for(vector<T>&t:v)prsp(t),ln;}
template<typename T, typename U>invd prln(T first, U second) {pr(first),ln,pr(second);}
template<typename T, typename... Args>invd prln(T first, Args... args) {pr(first),ln,prln(args...);}
template<typename T, typename... Args>invd pr(T first, Args... args) {pr(first),sp,pr(args...);}
templ1 vector<T>& operator+=(vector<T>& v,T x) {v.push_back(x);return v;}
templ1 vector<T>& operator--(vector<T>& v) {v.pop_back();return v;}templ1 vector<T>& operator--(vector<T>& v,int) {v.pop_back();return v;}
templ1 bool operator!(stack<T>&q) {return !q.empty();}templ1 stack<T>& operator+=(stack<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(stack<T>& v) {v.pop();return v.top();}templ1 T operator--(stack<T>& v,int) {T t=v.top();v.pop();return t;}
templ1 bool operator!(queue<T>&q) {return !q.empty();}templ1 queue<T>& operator+=(queue<T>& v,T x) {v.push(x);return v;}
templ1 T operator--(queue<T>& v) {v.pop();return v.front();}templ1 T operator--(queue<T>& v,int) {T t=v.front();v.pop();return t;}
template<tnm T,tnm U>invd smax(T&a,U b){if(b>a)a=b;}template<tnm T,tnm U>invd smin(T&a,U b){if(b<a)a=b;}
template<tnm T,tnm U>inline T gcd(T a, U b){return __gcd(a,b);}typedef vector<int> vi;typedef vector<vi > vvi;typedef pair<int, int> pii;typedef pair<ll,ll> pll;
int getint(){
  int x;scan(x);return x;
}
#define gi getint()

typedef vector<pii > vpii;
typedef vector<ll > vll;
ll MOD = 1E9+7;
const ll linf=~(1ll<<63);
const int inf=~(1<<31);
const int sk = 1E9;

struct mem{
  int loc, size, id;
  void print(){
    pr(loc,size);
  }
};

struct problem{
  int a, b, c, d;

  int last = 0;

  int solve(){
    int n = a+b;
    if(abs(c-d)>1)return pr(-1);
    if(min(a,b)<max(c,d))return pr(-1);
    if(d+1==c){
      string s(n,'4');
      s.back()='7';
      b--;
        bool e = 1;
      fr(i,1,n-1){
        if(b>d){
          s[i]='7';
          b--;
        }
        else if(e=!e){
          s[i]='7';
          d--;
          b--;
          if(b==0)break;
        }
      }
      pr(s);

    }else if(c+1==d){
      string s(n,'7');
      s.back()='4';
      a--,d--;
      ff(i,1,n){
        if(i&1||d<=0){
          s[i]='4';
          d--;
          a--;
          if(a==0)break;
        }
      }
      pr(s);

    }else if(c==d){
      if(a>c){
        string s(n,'4');
        d--;
        bool e = 1;
        fr(i,1,n-1){
            if(b>d){
              s[i]='7';
              b--;
            }
            else if(e=!e){
            s[i]='7';
            d--;
            b--;
            if(b==0)break;
          }
        }
        pr(s);
      }else if(b>c){
        string s(n,'7');
        a--;
        d--;
        ff(i,1,n){
          if(i&1||d<=0){
            s[i]='4';
            d--;
            a--;
            if(a==0)break;
          }
        }
        pr(s);

      }else return pr(-1);

    }
  }

  problem(){
    scan(a,b,c,d);
  }

};

int main(){
  init(1);
  problem px = {};
  px.solve();
}