#include <bits/stdc++.h>
using namespace std;
const int Inf = 1e9 + 7;
const int N = 100007;
int n, c[N];
string s[N], sr[N];
long long dp[N][2];
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> c[i];
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 0; i < n; ++i) {
    sr[i] = s[i];
    reverse(sr[i].begin(), sr[i].end());
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[1][0] = 0;
  dp[1][1] = c[0];
  for (int i = 1; i < n; ++i) {
    if (s[i] >= s[i - 1]) dp[i + 1][0] = min(dp[i + 1][0], dp[i][0]);
    if (s[i] >= sr[i - 1]) dp[i + 1][0] = min(dp[i + 1][0], dp[i][1]);
    if (sr[i] >= s[i - 1]) dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + c[i]);
    if (sr[i] >= sr[i - 1]) dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + c[i]);
  }
  long long res = min(dp[n][0], dp[n][1]);
  if (res == 0x3f3f3f3f3f3f3f3f)
    cout << "-1" << '\n';
  else
    cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(9);
  cout << fixed;
  solve();
  return 0;
}
