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