#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, l = 0, m = 0;
  string s;
  cin >> n;
  cin >> s;
  for (i = 0; i < s.length(); i++) {
    if (s[i] == '0' || s[i] == '1' || s[i] == '2' || s[i] == '3' ||
        s[i] == '5' || s[i] == '6' || s[i] == '8' || s[i] == '9') {
      cout << "NO";
      return 0;
    }
  }
  for (int i = 0; i < n / 2 - 1; i++) {
    for (int j = i + 1; j < n / 2; j++) {
      if (s[i] > s[j]) {
        swap(s[i], s[j]);
      }
    }
  }
  for (int i = 0; i < n / 2; i++) {
    if (s[i] == '4') {
      l++;
    }
  }
  for (int i = n / 2; i < s.length() - 1; i++) {
    for (int j = i + 1; j < s.length(); j++) {
      if (s[i] > s[j]) {
        swap(s[i], s[j]);
      }
    }
  }
  for (int i = n / 2; i < s.length(); i++) {
    if (s[i] == '4') {
      m++;
    }
  }
  if (l == m) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
