You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
570 B

#include <bits/stdc++.h>
using namespace std;
int main() {
//读入输出优化的强迫症
ios::sync_with_stdio(false);
int n;
cin >> n;
int a = 0, b = 0;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp;
if (tmp == 5) a++;
else b++;
}
if (!b) {
cout << -1;
return 0;
}
for (int i = 0; i < a / 9; i++) {
cout << "555555555";
}
if (a / 9 == 0) {
cout << 0;
return 0;
}
for (int i = 0; i < b; i++) {
cout << 0;
}
return 0;
}