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