#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i = 0, j, cnt, sum1 = 0, sum2 = 0;
  char s[100], ch;
  cin >> n;
  while (i != n) {
    cin >> ch;
    if (ch != '4' && ch != '7') {
      cout << "NO" << endl;
      return 0;
    } else {
      if (i < n / 2)
        sum1 += ch - '0';
      else
        sum2 += ch - '0';
    }
    i++;
  }
  if (sum1 == sum2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
