#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int n, i, sum = 0, siz = 1, sum1 = 0;
  cin >> n;
  cin >> str;
  for (i = 0; i < str.size(); i++) {
    if (siz <= n / 2) {
      if (str[i] == '4') {
        sum = sum + 1;
      } else if (str[i] == '7') {
        sum = sum + 7;
      } else {
        sum = 0;
      }
    }
    if (siz > n / 2) {
      if (str[i] == '4') {
        sum1 = sum1 + 1;
      } else if (str[i] == '7') {
        sum1 = sum1 + 7;
      } else {
        sum1 = 0;
      }
    }
    siz++;
  }
  if (sum == sum1 && sum != 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
