#include <bits/stdc++.h>
using namespace std;
vector<int> myvec;
map<int, int> mymap;
set<int> q;
int main() {
  int n, f = 0, sumfh = 0, sumlh = 0;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (i + 1 <= (n / 2))
      sumfh += s[i] - '0';
    else
      sumlh += s[i] - '0';
    if (s[i] == '4' || s[i] == '7') {
      f = 0;
      continue;
    } else {
      f = 1;
      break;
    }
  }
  if (f == 1) {
    cout << "NO" << endl;
    return 0;
  } else {
    if (sumfh == sumlh)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
