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