#include <bits/stdc++.h>
using namespace std;
bool lucky(const char *str) {
  for (; *str; ++str) {
    if (*str != '4' && *str != '7') return false;
  }
  return true;
}
int main() {
  int l, sl = 0, sr = 0;
  string ticket;
  (cin >> l, l);
  (cin >> ticket, ticket);
  if (!lucky(ticket.c_str())) {
    cout << ("NO");
  } else {
    for (int i = (0); i < (l / 2); ++i) sl += ticket[i] - '0';
    for (int i = (l / 2); i < (l); ++i) sr += ticket[i] - '0';
    if (sl != sr) {
      cout << ("NO");
    } else {
      cout << ("YES");
    }
  }
  return 0;
}
