#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int prime;
  for (int i = 0; i < n; i++) {
    if (s[i] == '4' || s[i] == '7') {
      prime = 1;
    } else {
      prime = 0;
      break;
    }
  }
  int p;
  for (int i = 0; i < n / 2; i++) {
    p = 0;
    for (int j = n / 2; j < n; j++) {
      if (s[i] == s[j]) {
        s[j] = '0';
        p = 1;
        break;
      }
    }
    if (p == 0) break;
  }
  if (p == 1 && prime) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
