#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i = 0, lhs = 0, rhs = 0;
  string s;
  cin >> n >> s;
  for (i; i < n; i++) {
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO\n";
      return 0;
    }
    if (i < n / 2)
      lhs += s[i] - '0';
    else
      rhs += s[i] - '0';
  }
  cout << (lhs == rhs ? "YES\n" : "NO\n");
}
