Algorithm


A. Lucky Sum of Digits
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 477444 are lucky and 517467 are not.

Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with the task.

Input

The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.

Output

Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.

Examples
input
Copy
11
output
Copy
47
input
Copy
10
output
Copy
-1



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>

int main(){

    long n(0); scanf("%ld", &n);

    long numSevens(-1), numFours(-1), minDigits(1e6);

    for(long testSevens = n / 7; testSevens >= 0; testSevens--){
        if((n - 7 * testSevens) % 4 != 0){continue;}
        long testFours = (n - 7 * testSevens) / 4;
        numSevens = testSevens; numFours = testFours; 
        minDigits = numSevens + numFours;
        break;
    }

Copy The Code & Try With Live Editor

Input

x
+
cmd
11

Output

x
+
cmd
47
Advertisements

Demonstration


Codeforces Solution-A. Lucky Sum of Digits-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+