#include <bits/stdc++.h>
using namespace std;
int main() {
  bool r = 1;
  long long a, z = 0, x = 0, c = 0, v = 0;
  string b, s1, s2;
  cin >> a >> b;
  s1 = b.substr(0, a / 2);
  s2 = b.substr(a / 2, a / 2);
  for (long i = 0; i < b.length(); i++) {
    if (b[i] != '7') {
      if (b[i] != '4') {
        r = 0;
        break;
      }
    }
  }
  if (r == 0)
    cout << "NO";
  else {
    for (long i = 0; i < s1.length(); i++) {
      if (s1[i] == '7') z++;
      if (s2[i] == '7') c++;
      if (s1[i] == '4') x++;
      if (s2[i] == '4') v++;
    }
    if (z == c && x == v)
      cout << "YES";
    else {
      cout << "NO";
    }
  }
}
