#include <bits/stdc++.h>
using namespace std;
int str2int(const string &str) {
  stringstream ss(str);
  int n;
  ss >> n;
  return n;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    if (i < n / 2) {
      a += str2int(s.substr(i, 1));
    } else {
      b += str2int(s.substr(i, 1));
    }
    if (s[i] == '4' || s[i] == '7') {
    } else {
      cout << "NO";
      return 0;
    }
  }
  if (a == b) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
