#include <bits/stdc++.h>
using namespace std;
string str;
int main() {
  long long x, z, flag = 0, num = 0, fst = 0, snd = 0;
  cin >> x >> str;
  for (int i = 0; i < x; i++) {
    if (str[i] == '4' || str[i] == '7') {
      if (i < x / 2)
        fst += str[i] - 48;
      else
        snd += str[i] - 48;
    } else
      flag = 1;
  }
  if (fst == snd && flag == 0) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
