#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int len = s.length();
  bool flag = false;
  for (int i = 0; i < len; i++) {
    if (s[i] == '4' || s[i] == '7')
      continue;
    else {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "NO" << endl;
  } else {
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < (len / 2); i++) sum1 += (s[i] - '0');
    for (int i = (len / 2); i < len; i++) sum2 += (s[i] - '0');
    if (sum1 == sum2)
      cout << "YES" << endl;
    else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
